Tuesday, March 27, 2012

exec statement

hi guys

maybe an easy one for you

in stored procedure I create follving select

@.cmd = 'select ' + @.column_name + 'from ticket_dump_datawarehouse '
execute (@.cmd)

problem is thant I want to gave return value from this select

something like
set @.return = execute(@.cmd)

but I recieve error

Incorrect syntax near the keyword 'execute'

Can I do that some other way?create temporary table out the and insert the result into that table
create table #t(colvalue <datatype>)

@.cmd = 'insert into #t (colvalue)
select ' + @.column_name + 'from ticket_dump_datawarehouse '
execute (@.cmd)

select * From #t

drop table #t

No comments:

Post a Comment