Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2004, 08:34 PM
Authorized User
 
Join Date: Jun 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default #temp table object_id

How come when I create a temp table as below, It does not show up in my OBJECT_ID? What I really need to do is test for the existence of a given temp table and drop it if it exists or create it if it doesn’t.

CREATE TABLE #text (text_key VARCHAR (255), text_string TEXT NULL)
Select OBJECT_ID('#MyTempTable')

RETURNS:
NULL


_________________________
Joe Horton
Database Developer / Software Engineer
WISHA/Legal Services Software Development
Department of Labor and Industries
Voice (360) 902-5928 fax (360) 902-6200
__________________
_________________________
Joe Horton
Database Developer / Software Engineer
WISHA/Legal Services Software Development
Department of Labor and Industries
Voice (360) 902-5928 fax (360) 902-6200
 
Old March 22nd, 2004, 08:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Refer to the #temp table prefixing the database name (tempdb):
Code:
SELECT OBJECT_ID('tempdb..#text')
P.S. Remember that the temp table will be automatically deleted when the connection which created it goes away...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
temp table in query abdusalam Access 5 January 9th, 2008 09:28 AM
TEMP TABLE TO REAL TABLE pallone SQL Server 2000 2 June 15th, 2007 07:50 AM
How to use CTE instead of temp table jayaraj123 SQL Server 2005 0 April 25th, 2007 08:03 PM
Copy whole structure of table in #temp table maulik77 SQL Server 2000 2 December 21st, 2006 02:42 AM
global temp table vs.permanent table use sofya SQL Server 2000 0 December 17th, 2004 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.