首页 > 数据库技术 > 详细

What is the use of GO in SQL Server Management Studio & Transact SQL?

时间:2021-04-30 15:38:57      阅读:20      评论:0      收藏:0      [点我收藏+]

What is the use of GO in SQL Server Management Studio & Transact SQL?

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?

 

回答1

It is a batch terminator, you can however change it to whatever you want

技术分享图片

 

 

回答2

Just to add to the existing answers, when you are creating views you must separate these commands into batches using go, otherwise you will get the error ‘CREATE VIEW‘ must be the only statement in the batch. So, for example, you won‘t be able to execute the following sql script without go

create view MyView1 as
select Id,Name from table1
go
create view MyView2 as
select Id,Name from table1
go

select * from MyView1
select * from MyView2

 

What is the use of GO in SQL Server Management Studio & Transact SQL?

原文:https://www.cnblogs.com/chucklu/p/14721099.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!