|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hallo!
I have a problem with my sql server. I create a temporary table, like so: Code:
create table #tempTable ( userId int ) But when I try to drop the same table: Code:
drop table #tempTable I get this error: Code:
Server: Msg 3701, Level 11, State 5, Line 2 Cannot drop the table '#tempTable', because it does not exist in the system catalog. And when I try to create the table once more, I get this error(of course): Code:
Server: Msg 2714, Level 16, State 6, Line 1 There is already an object named '#tempTable' in the database. I canŽt find the tableobject in the sysobjects table. I have no Idea whats going on!? Thanks for reading, greateful for any suggestions /mats |
|
#2
|
||||
|
||||
|
can you verify in the database that the table gets created?
|
|
#3
|
|||
|
|||
|
Quote:
IŽll think there is where the temporary tables are suposed to be created, right? I can find the table by running: Code:
from tempdb..sysobjects where name LIKE '#tempTable%' But I cant delete it with Code:
drop table #tempTable I have even tried to run the 'drop table' code in the tempDb datebase. But I still get the same error: Code:
Server: Msg 3701, Level 11, State 5, Line 1 Cannot drop the table '#tempM', because it does not exist in the system catalog. and I still cant create the table oveer again. Can I delete the row from the tempDb.sysObject table manually without damaging my sqlsqrver? |
|
#4
|
|||
|
|||
|
Try this:
Always use "dbo." as prefix to your temp tables. When trying to drop it, check with "tempdb.dbo." as prefix. IF OBJECT_ID('tempdb.dbo.#mytemptable') IS NOT NULL DROP TABLE dbo.#mytemptable CREATE TABLE dbo.#mytemptable ... ... IF OBJECT_ID('tempdb.dbo.#mytemptable') IS NOT NULL DROP TABLE dbo.#mytemptable I hope that solves it |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Server: Msg 3701 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|