Hello everyone,
I am not sure how to compare the result of a dynamic sql stmt in t-sql. Sorry if it is a dummy question.
For example:
declare
@v_test varchar(10),
@v_table varchar(20)
set @v_table = 'emp'
-- this works
exec ('select top 1 description from ' + @v_table)
-- but what I need now is to compare the value of description with some pre defined value.
if ('X' = exec ('select top 1 description from ' + @v_table))
....
I do not see a way to do this. Any help is greatly appreciated.
Thanks,
--aa
I am not sure how to compare the result of a dynamic sql stmt in t-sql. Sorry if it is a dummy question.
For example:
declare
@v_test varchar(10),
@v_table varchar(20)
set @v_table = 'emp'
-- this works
exec ('select top 1 description from ' + @v_table)
-- but what I need now is to compare the value of description with some pre defined value.
if ('X' = exec ('select top 1 description from ' + @v_table))
....
I do not see a way to do this. Any help is greatly appreciated.
Thanks,
--aa