SQL Server: What are batching statements (i.e. using “GO”) good for?

后端 未结 4 2028
無奈伤痛
無奈伤痛 2020-12-08 03:47

I know that in SQL Server GO is considered a batch separator.

My question is: What is the point of having a batch separator? What benef

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 04:17

    In the example there it is of no use whatsoever.

    Lots of statements must be the only ones in the batch however.

    Such as CREATE PROCEDURE.

    Also often after making schema changes (e.g. adding a new column to an existing table) statements using the new schema must be compiled separately in a different batch.

    Generally an alternative to submitting separate batches separated by GO is to execute the SQL in a child batch using EXEC

提交回复
热议问题