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
 SQL Server Development (2000)
 Temporary tables

Author  Topic 

mb
Starting Member

16 Posts

Posted - 2002-04-29 : 11:02:30
How can I find out if a temporary table has been created already in a session? They dont seem to show up in the sysobjects table for some reason.


YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-04-29 : 11:10:05
Temporary tables will be listed in tempdb..sysobjects

IF (object_id('tempdb..#mytemp') IS not Null)
Drop Table #mytemp

Although `tempdb..#authors_temp' is a truncation of the actual physical name of the object as held in tempdb..sysobjects, somehow OBJECT_ID() recognizes that you mean "your" temporary table called #mytemp.
Go to Top of Page

greatfung
Starting Member

1 Post

Posted - 2002-04-30 : 01:38:09
How can I do so in ASP?

I'd tried the following statement:

conn.Execute("if (object_id(tempdb..#mytemp) is not null) drop table #mytemp")

but the following error message was shown:

[INTERSOLV][ODBC SQL Server driver][SQL Server]The column prefix 'tempdb.' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.
Go to Top of Page

mohamedyousuff@yahoo.com
Starting Member

24 Posts

Posted - 2002-04-30 : 04:29:12

That is just syntax error. Single quote is missing for the object_id parameter. Try this


conn.Execute("if (object_id('tempdb..#mytemp') is not null) drop table #mytemp")


quote:

How can I do so in ASP?

I'd tried the following statement:

conn.Execute("if (object_id(tempdb..#mytemp) is not null) drop table #mytemp")

but the following error message was shown:

[INTERSOLV][ODBC SQL Server driver][SQL Server]The column prefix 'tempdb.' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.



Go to Top of Page
   

- Advertisement -