What is the difference between ; and GO in stored procedure in SQL Server?

后端 未结 5 2261
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-18 18:16

What is the difference between ; and GO in stored procedure in SQL Server ?

Actually, if I have a stored procedure in SQL server and wanna to p

5条回答
  •  一整个雨季
    2021-02-18 18:55

    GO is not a command to the server, it's the default batch separator for most of the client tools the MS supply. When the client tool encounters "GO" on a new line by itself, it sends whatever commands it has accumulated thus far to the server, and then starts over anew.

    What this means is that any variables declared in one batch are not available in subsequent batches. And it also means that multi-line comments can't be placed around a "GO" command - because the server will see the first batch, and see an unterminated comment.

提交回复
热议问题