Check existance of a view by using OBJECT_ID : OBJECT_ID « System Settings « SQL Server / T-SQL Tutorial






6> IF OBJECT_ID('dbo.VCustsWithOrders') IS NOT NULL
7>   DROP VIEW dbo.VCustsWithOrders;
8> GO








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