Question: I have two query. create new view and update view query.

1) vw\_delay (new),

```
CREATE VIEW vw_delay AS
        SELECT ....

```

2) vw\_RDoc (exist)

```
 ALTER VIEW vw_RDoc AS
        SELECT ....

```

I want to run both query as single query. I tried to run like this,

```
CREATE VIEW vw_delay AS
            SELECT ....
  ALTER VIEW vw_RDoc AS
            SELECT ....

```

but it returns this error:

> 
> Msg 156, Level 15, State 1, Procedure vw\_delay, Line 7  
> 
>  Incorrect syntax near the keyword 'ALTER'. 
> 
> 
> Msg 111, Level 15, State 1, Procedure vw\_delay, Line 7  
> 
>  'ALTER VIEW' must be the first statement in a query batch.
> 
> 
> 

How to do this? Please help me.

Answer: 
What is necessary to do is add GO after first CREATE VIEW.

```
CREATE VIEW vw_delay AS
            SELECT ....
GO
  ALTER VIEW vw_RDoc AS
            SELECT ....

```

Then it will work.
Use batch terminator 'GO'. it will separate the both batches and then it will work fine

```
CREATE VIEW YourViewName AS
SELECT * FROM tablex

GO

ALTER VIEW YourViewName AS
SELECT * FROM tabley

```