Cam you insert the results of a dynamic sql call into a SQL Server 2005 table variable

Posted by codingguy3000 on Stack Overflow See other posts from Stack Overflow or by codingguy3000
Published on 2010-04-22T18:58:06Z Indexed on 2010/04/22 19:03 UTC
Read the original article Hit count: 189

Filed under:
|

Is there anyway to do this in SQL Server 2005?

declare @tv_tablelist table (recnum int identity(1,1) primary key, newvar varchar(500))

declare @mysql nvarchar(4000)

set @mysql = 'insert into @tv_tablelist(newvar) values (''test test test'')'


      Exec sp_executesql @mysql,      
            N'@tv_tablelist table (recnum int identity(1,1) primary key, newvar varchar(500)) OUTPUT',      
      @tv_tablelist OUTPUT  

select * from @tv_tablelist

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2005