In SQL Server, when should you use GO and when should you use semi-colon ;?

后端 未结 5 1804
南方客
南方客 2020-12-04 10:51

I’ve always been confused with when I should use the GO keyword after commands and whether a semi-colon is required at the end of commands. What is the differences and why/w

5条回答
  •  鱼传尺愫
    2020-12-04 11:23

    GO only relates to SSMS - it isn't actual Transact SQL, it just tells SSMS to send the SQL statements between each GO in individual batches sequentially.

    The ; is a SQL statement delimiter, but for the most part the engine can interpret where your statements are broken up.

    The main exception, and place where the ; is used most often is before a Common Table Expression Statement.

提交回复
热议问题