Naitik Gamit
asked on
SQL Get Store Procedure Column Name As Row
I want to retrieve store procedure columns as row without data.
for example I have store procedure SP_Get_All_Country_List with parameter @Return_Data BIT. If I pass Return_Data=1 then it return value but when I pass Return_Data=0 then no data return.
EXEC SP_Get_All_Country_List @Return_Data=0
it show blank columns as :
Country_ID Country_Name Country_Region
Now I want this as :
Country_ID
Country_Name
Country_Region
I don't want data I only want column names as row. simply I want store procedure all columns list.
for example I have store procedure SP_Get_All_Country_List with parameter @Return_Data BIT. If I pass Return_Data=1 then it return value but when I pass Return_Data=0 then no data return.
EXEC SP_Get_All_Country_List @Return_Data=0
it show blank columns as :
Country_ID Country_Name Country_Region
Now I want this as :
Country_ID
Country_Name
Country_Region
I don't want data I only want column names as row. simply I want store procedure all columns list.
You'll need to change the SP to act as required.
afaik this is not possible, especially when a SP can return different sets based on logic in the SP.
add this to sql
select Country_ID, Country_Name, Country_Region from someTable where 1=2
UNION
your existing query here...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks sameer2010 it works as i expect.