I have the below SQL statement which is being built up in the SP. What I need to do now is assign the result to a variable, but how do you do this when you need to execute the @sql??
SET @SQL='SELECT id FROM table WHERE id='+@id+' AND name='+@name+''
SET @var = exec(@sql)
which doesn't work??
SET @SQL='SELECT id FROM table WHERE id='+@id+' AND name='+@name+''
SET @var = exec(@sql)
which doesn't work??