If I go to the View Details tab for a view and select that I want it to generate the drop statements before the create statements, the drop statements that are generated are similar to:
USE [databaseName];
GO
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N’[dbo].[view_name]’))
BEGIN
USE [databaseName];
GO
DROP VIEW [dbo].[view_name];
GO
END
GO
This errors out on the “Use …” and “GO” statements that occur between the “BEGIN” and “END” of the “IF”. It should generate something similar to the following:
USE [databaseName];
GO
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N’[dbo].[view_name]’))
BEGIN
DROP VIEW [dbo].[view_name];
END
GO
Jeffrey Bradley