i need to put the result of quey @st into a variable. could anyone please tell me how to do that?
select @sys= + columnName+', ' from tab
set @sys=left(@sys, len(@sys)-1)
select @sys
DECLARE cursor_insert CURSOR FOR
SELECT insequenceid FROM temp_ac
OPEN cursor_insert
FETCH NEXT FROM cursor_Insert into @inseq
WHILE @@FETCH_STATUS = 0
BEGIN
set @st= ('select ' + @sys + ' from temp_ac ')
execute (@st)
FETCH NEXT FROM cursor_Insert into @inseq
END
CLOSE cursor_insert
DEALLOCATE cursor_insert
i want something so that @val= execute(@st)?????