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)
 avoiding locks on tempdb

Author  Topic 

dursaliye
Starting Member

22 Posts

Posted - 2005-08-30 : 00:48:49

I read that "SELECT INTO ... #temptable" creates locks on tempdb so we should use "INSERT #temptable SELECT ...".
I also read that while we use "INSERT #temptable EXECUTE spName" from within stored procedure, locks on syscolumns, sysobjects, and sysindexes on tempdb are created, and so we should avoid using "INSERT #temptable EXECUTE spName".
I suppose those of three statements use tempdb, so locks are created on those tables except "SELECT INTO ... #temptable" because this also creates a temp table, and so this statement's execution time is longer. Am I wrong or if I'm right, then what should we use from within a stored procedure (not a local or global stored procedure)?
   

- Advertisement -