Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am Having one Stored Procedure which will return Dynamic Column based on Parameter passed.
for example
if Parameter passed Branchcode=0999 then in my select list
column will be clientCode, ClientName,BranchCode

similarly if passed parameter as Age,Gender
column will be clientCode, ClientName,BranchCode,Age,Gender
....
number of columns is variable.

i want above stored procedure result into table varible
and after that based on number of rows. i have to perform another operation.

please help
thanks
Posted

1 solution

I suggest that in all cases return the exact same structure from the stored procedure, only put NULL values for the columns you are not interested in for that specific case...That will enable you to use a single table to store the result and go forward with...
SQL
CREATE TABLE @myTable (
 -- your fields...
)

INSERT INTO @myTable
EXEC mySP (@param)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900