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
 Transact-SQL (2000)
 Dropping temp tabe

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-07-25 : 09:45:51
I have a Store procedure that has a the code
drop table #temp_table ,which is used to drop the temp table, but am getting a error each time the Store procedure from a SQL Task in my DTS package, does the Table get dropped after it goes out of scope it seems that way to me ?

humanpuck
Yak Posting Veteran

94 Posts

Posted - 2006-07-25 : 10:12:27
When you execute the procedure for QA does it error out or run fine?
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-07-25 : 10:20:53
rookie_sql: yes, the drop must be within the same scope if you wish to explicitly do this

--------------------
keeping it simple...
Go to Top of Page

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-07-25 : 11:33:52
For some funny reason it works now, the first time i run the SP i did not excute the line as the table would not have been created, but the 2nd time it would have created the table and should have dropped it, but i was getting a error i run the SP in the QA seperate to the DTS and it worked fine then i ran the SP from the SQL task and it now works fine... strange .. or what !!!
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-07-25 : 13:11:29
you could also check if the temp table exists before you try to drop it
IF OBJECT_ID('tempdb..#YourTempTable') IS not NULL 
BEGIN
drop table #YourTempTable
END


Help us help YOU!
Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page
   

- Advertisement -