What is the use of GO in SQL Server Management Stu

2019-01-01 01:49发布

SQL Server Management Studio always inserts a GO command when I create a query using the right click "Script As" menu. Why? What does GO actually do?

8条回答
呛了眼睛熬了心
2楼-- · 2019-01-01 02:37

Since Management Studio 2005 it seems that you can use GO with an int parameter, like:

INSERT INTO mytable DEFAULT VALUES
GO 10

The above will insert 10 rows into mytable. Generally speaking, GO will execute the related sql commands n times.

查看更多
与风俱净
3楼-- · 2019-01-01 02:37

Here is the magic of GO.

SELECT 'Go'
Go 10

SYNTAX : Go INT (BatchNumber)

BatchNumber: No of times occurred

Looks simple,It might lead you to Spaghetti if you code deeper.

查看更多
登录 后发表回答