Priya
3/9/2007 9:10:00 AM
Hey all,
I have a query which returns the name field from a table. I use the
sp_executesql to execute this query. The code looks like,
SET @Query = 'SELECT ' + @TableName + 'Name' + 'FROM' + @TableName + '
WHERE ' + @TableName + 'ID = ' + @ID
EXEC @Name = sp_executesql @Query
SELECT @Name
IF @Name = @Value
BEGIN
........
END
I get the corresponding name from the query but the statement SELECT
@Name returns 0. I need to compare the name value with another
variable and do some more operations. How to store the name in this
procedure? Any help would be appreciated
Thanks in advance