November 30, 2007 at 10:03 am
Hi
How to check using T-SQL whether a global temp table exists ?
Any one help me ????
:):):)
thanks
venkat
November 30, 2007 at 10:14 am
I got it...
DECLARE @temp_table VARCHAR(100)
SET @temp_table = '##my_temp_table'
IF NOT EXISTS (SELECT 'x'
FROM tempdb..sysobjects
WHERE type = 'U' and NAME = @temp_table)
PRINT 'temp table ' + @temp_table + ' does not exist'
ELSE
PRINT 'temp table ' + @temp_table + ' exists.'
thanks
November 30, 2007 at 11:55 am
IF OBJECT_ID('TempDB..##my_temp_table','U') IS NOT NULL
PRINT 'Table Exists'
ELSE
PRINT 'Table does not Exist'
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy