How to get multiple result set on conditional basis and also retrieve the column name
I want to get the name as Col1, Col2, Col3, Col4 etc. as per the result set.
I have a store procedure which looks like
CREATE SP Test
(@Id INT)
AS
BEGIN
IF(@Id ==1)
BEGIN
SELECT Col1, Col2 from Table1
END
IF(@Id ==2)
BEGIN
SELECT Col1, Col2, Col3 from Table1
END
ELSE
BEGIN
SELECT Col4, Col3 from Table1
END
END

Vinay SinghPosted Aug 2, 2016, 1:11 PM
Anil Kumar MurmuPosted Aug 2, 2016, 10:11 AM
Yes, Bikesh
Depending on input parameter, we will have separate result sets. If input parameter is 1 then columnsreturned would be col1 and col2
Bikesh SrivastavaPosted Aug 2, 2016, 10:03 AM