Tuesday 19 February 2013

Check if a Temporary table exists


To check if a temporary table exists,The usual method of querying sys.objects table on tempdb will not store #tables in the same naming convention as we create, So one of the best way to check if a #table exists is as below,

IF object_id('tempdb..#MyTempTable') IS NOT NULL
BEGIN
<TSQL Batch>
END

No comments:

Post a Comment