Link to home
Start Free TrialLog in
Avatar of purplesoup
purplesoupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Creating a SQL Script (batch) file with multiple create view statements

I want to create a Microsoft SQL script file that creates multiple views in a database, and can be run multiple times without an error.

Is this possible. The code below will work, but it won't run a second time without an error. If I add an existence check I get an error that the create view statement isn't the first in the batch, is there a way around this problem?
create view v1
as 
select top 5 * from Name
go
 
create view v2
as
select top 6 * from Name
go

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial