Hi I have something like this in my store procedure,
SET @SQl = 'Some query' --this query return only a cell the type int
SET @VAR = exec(@SQL) --the varaible @var it's local and the type int
How can i get the return value of the query and set to the variable, it's possible?? or what I'm doing it's wrong???
Thanks for your help
If the query returns a scalar result set you need to do
Much better to use
sp_executesql
andOUTPUT
parameters