goofaholix
MIS
I have a dynamic sql statement that when executed returns a list of columns, I want to insert the results of this into a second dynamic sql statement as a list of columns that the second statement will return.
The first statement returns something like;
column1,
column2,
column3,
The second statement is something like;
SET @statement2 = 'Select
UID,Type,' + @statement1 + '
getdate()
FROM table
Where ID in (' @parameter ')'
When I do the above it prints the first statement inside the second whereas I want to execute the first statement inside the second.
The reason i need to do this is that the first statement determines which columns are appropriate to be included thin the select statement of the second statement based on the parameter.
Any idea how I should do this?
thanks.
Bruce
The first statement returns something like;
column1,
column2,
column3,
The second statement is something like;
SET @statement2 = 'Select
UID,Type,' + @statement1 + '
getdate()
FROM table
Where ID in (' @parameter ')'
When I do the above it prints the first statement inside the second whereas I want to execute the first statement inside the second.
The reason i need to do this is that the first statement determines which columns are appropriate to be included thin the select statement of the second statement based on the parameter.
Any idea how I should do this?
thanks.
Bruce