Revision: 31916
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 15, 2010 21:21 by hairajeshk
Initial Code
--Create table USE Norhtwind GO CREATE TABLE #temp(id INT) --Check if it exists IF OBJECT_ID('tempdb..#temp') IS NOT NULL BEGIN PRINT '#temp exists!' END ELSE BEGIN PRINT '#temp does not exist!' END --Another way to check with an undocumented optional second parameter IF OBJECT_ID('tempdb..#temp','u') IS NOT NULL BEGIN PRINT '#temp exists!' END ELSE BEGIN PRINT '#temp does not exist!' END --Don't do this because this checks the local DB and will return does not exist IF OBJECT_ID('tempdb..#temp','local') IS NOT NULL BEGIN PRINT '#temp exists!' END ELSE BEGIN PRINT '#temp does not exist!' END --unless you do something like this USE tempdb GO --Now it exists again IF OBJECT_ID('tempdb..#temp','local') IS NOT NULL BEGIN PRINT '#temp exists!' END ELSE BEGIN PRINT '#temp does not exist!' END
Initial URL
Initial Description
Verify whether temporary table created is exists or not
Initial Title
Check temporary table exists
Initial Tags
table
Initial Language
SQL