Link to home
Create AccountLog in
Avatar of Naitik Gamit
Naitik GamitFlag for India

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.
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

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...

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sameer2010
sameer2010
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Naitik Gamit

ASKER

Thanks sameer2010 it works as i expect.