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)
 Dowt in create temporary table

Author  Topic 

iswan
Starting Member

28 Posts

Posted - 2007-07-23 : 10:16:35

create temp table using exec:
set str='create table #scDataImportTest(ChapterNo varchar(150),FigureNo varchar(50))'
exec(str)
select * from #scDataImportTest


Error: Invalid obj #scDataImportTest

But If I am creating a physical table using this. It is creating correctly

set str='create table scDataImportTest(ChapterNo varchar(150),FigureNo varchar(50))'
exec(str)
select * from scDataImportTest


I just removed the '#' from the query. It is working fine. I don't know How to create Temporary table using this exec

Regards
Iswan



blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2007-07-23 : 10:48:08
Temporary tables exist only within the scope of the transaction, unless they are declared to be global. EXEC statements execute within their own scope, so temporary tables created by them vaporize when the statement completes. You could try bundling your SELECT clause in your EXEC string.

e4 d5 xd5 Nf6
Go to Top of Page
   

- Advertisement -