mataichi
06-05-2009, 04:40 PM
Hi,
I am trying to fetch a value from a table within a stored procedure using dynamic sql. Seems that only dynamic sql can be used with EXEC() and the like.
Basically I want to do this....
SELECT @MyValue = @MyDBField FROM @MyDBTable WHERE MyID=@N
But it keeps giving me errors because of the variables.
I'd rather not have to create another stored procedure to output the value based on the parameters, but is that the only way?
Thanks!
I am trying to fetch a value from a table within a stored procedure using dynamic sql. Seems that only dynamic sql can be used with EXEC() and the like.
Basically I want to do this....
SELECT @MyValue = @MyDBField FROM @MyDBTable WHERE MyID=@N
But it keeps giving me errors because of the variables.
I'd rather not have to create another stored procedure to output the value based on the parameters, but is that the only way?
Thanks!