Code that tests for the existence of a temporary table : OBJECT_ID « System Settings « SQL Server / T-SQL Tutorial






IF OBJECT_ID('tempdb..#AllUserTables') IS NOT NULL
    DROP TABLE #AllUserTables








26.21.OBJECT_ID
26.21.1.The syntax of the OBJECT_ID function
26.21.2.Code that tests for the existence of a temporary table
26.21.3.SELECT object_id('employee')
26.21.4.Check existance of a view by using OBJECT_ID
26.21.5.Use OBJECT_ID in insert statement