Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 14th, 2004, 09:52 AM
mats mats is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: sweden
Posts: 10 mats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Server: Msg 3701

Hallo!

I have a problem with my sql server.
I create a temporary table, like so:
Code:
create table #tempTable (
userId int
) 
This works just fine
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

Reply With Quote
  #2  
Old October 14th, 2004, 09:26 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
can you verify in the database that the table gets created?

Reply With Quote
  #3  
Old October 15th, 2004, 02:38 AM
mats mats is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: sweden
Posts: 10 mats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Memnoch
can you verify in the database that the table gets created?
Yes actually now I found the tablename in the sysobjects table in the tempDb database.
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?

Reply With Quote
  #4  
Old December 1st, 2004, 12:58 AM
Jonas Molander Jonas Molander is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 Jonas Molander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Server: Msg 3701


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT