I have a stored proc in sql server 2000. I need to set a variable using a dynamic query:
set @SQLstring = 'select ' + @x1 + ' from tblAssettype where assettypeid = ' + cast(@atype as varchar(18))
EXEC(@SQLstring)
This works fine and returns a string. However, I have to run this query in a multi statement sp so I need to use the value it returns in another statement.
How can I get this value. I cannot do the following
set @x2 = EXEC(@SQLstring)
so how can I get my hands on the result of this query within the same stored procedure.
Thanks for any help on this
set @SQLstring = 'select ' + @x1 + ' from tblAssettype where assettypeid = ' + cast(@atype as varchar(18))
EXEC(@SQLstring)
This works fine and returns a string. However, I have to run this query in a multi statement sp so I need to use the value it returns in another statement.
How can I get this value. I cannot do the following
set @x2 = EXEC(@SQLstring)
so how can I get my hands on the result of this query within the same stored procedure.
Thanks for any help on this