Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 create temp table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-09-21 : 07:24:29
Robert writes "Is it possible to create a temporary table utilizing EXECUTE and the Create Statement in a variable, for example:

Declare @sql varchar(1000)
set @sql = 'create table #table(field1 int, field2, char(2))'
execute(@sql)"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-21 : 07:31:47
Why do you want to use this?
You will lose the table scope after the execution
Anyway everything should be in same block

Declare @sql varchar(1000)
set @sql = 'create table #table(field1 int, field2 char(2))
Insert into #table values(1,''AB'')
Select * from #table'
execute(@sql)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -