views:

37

answers:

1

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
+4  A: 

If I understand what you require, have you tries something like

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

declare @mysql nvarchar(4000) 

set @mysql = 'SELECT ''test test test''' 

INSERT INTO @tv_tablelist Exec sp_executesql @mysql

select * from @tv_tablelist 

Output

recnum      newvar
----------- --------------
1           test test test
astander
+1, exactly what I was thinking!
KM
It works! Thank you!
codingguy3000