Avatar of Naitik Gamit
Naitik Gamit
Flag 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.
SQLDatabasesMicrosoft SQL Server

Avatar of undefined
Last Comment
Naitik Gamit

8/22/2022 - Mon
Vitor Montalvão

You'll need to change the SP to act as required.
Jim Horn

afaik this is not possible, especially when a SP can return different sets based on logic in the SP.
HainKurt

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

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
sameer2010

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Naitik Gamit

ASKER
Thanks sameer2010 it works as i expect.