Sql Server : How to check if a temporary tables exists
- Posted by Sqltimes
- On December 3, 2014
- 0 Comments
Quick one today:
Checking for existence of temporary tables is not the same as regular tables in user databases. See below:
1
2
3
4
5
6
7
8
9
10
11
12
|
-- -- Sample code to test the existence of temporary table -- CREATE TABLE #Customer( ID BIGINT NOT NULL PRIMARY KEY CLUSTERED , Exists_Flag BIT NOT NULL DEFAULT (0) ) GO IF OBJECT_ID( 'tempdb..#Customer' ) IS NOT NULL PRINT '#Customer Table Exists' GO |
Hope this helps,
_Sqltimes
_Sqltimes
0 Comments