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
 General SQL Server Forums
 New to SQL Server Programming
 TempTable

Author  Topic 

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2014-04-24 : 00:52:16
Hi all,

I have been using the temp table a lot for all my homework query but everytime when I stop the query in the middle of execution, I have to execute each line of Drop Table #tmptbl1 and so on until the last drop table #tmptbl. Is that any shortest way to handle temp table if we stop the query without manually highlight each line statement of Drop table #tmptbl.

Thank you

SQLBoy

WAmin
Starting Member

16 Posts

Posted - 2014-04-24 : 01:20:24
How about using Table variable?
DECLARE @tmptbl AS TABLE(ID INT)

Or you can look at the following link
http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2014-04-24 : 01:34:06
Hi, deciding on using Temp table or table variable , should depend on a few factors, such as amount of rows and index requirements. Check this post for differences between Temp table and table variable.
http://www.sqlserver-dba.com/2011/12/sql-table-variable-and-temporary-table.html

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -