Code: Select all
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[view1]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[view1]
GO
CREATE VIEW dbo.view1
AS
SELECT * FROM dbo.table1
go
Code: Select all
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[view1]'))
DROP VIEW [dbo].[view1]
GO
CREATE VIEW dbo.view1
AS
SELECT * FROM dbo.table1
GO
My current approach is to create a Lines to Omit pattern in the ruleset, with pattern ^IF\s*(NOT)*\s*EXISTS, and skipping 3 lines (these headers are auto-generated, so I can assume simple patterns).
A screenshot with the results is attached. What is wrong with my approach?