Thursday, September 29, 2011

Check temporary table exist or not in SQL Server

You can check temporary table exist or not in SQL Server, and this is the keyword :
IF OBJECT_ID('tempdb..#tmp_attendance') IS NOT NULL
begin
  drop table #tmp_attendance
end


It work !!!




PS : i tried this in SQL Server  =  Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)   Mar 29 2009 10:27:29   Copyright (c) 1988-2008 Microsoft Corporation  Express Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)








No comments: