TSQL中的GO语句是什么意思 [英] What's the meaning of the GO-statement in TSQL

查看:25
本文介绍了TSQL中的GO语句是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 TSQL 的新手,想知道 GO 语句的真正含义.对我来说,它似乎只是被扔在了它似乎适合的地方.

I'm new to TSQL and wondering what the GO statement really means. To me it just seems thrown in there where ever it seems to fit.

我猜它以某种方式告诉 sql server 运行前一条语句?如果您根本不使用它们会怎样?有人可以举一个例子,如果我不使用 GO 语句会中断.

I guess it somehow tells sql server to run the previous statement? What happens if you don't use them at all? Could someone give an example where a statement will break if I don't use a GO.

请详细说明.

推荐答案

是一个批处理终止器

这会坏的

declare @i int
set @i =5

declare @i int
set @i =6

Select @i

消息 134,级别 15,状态 1,第 5 行变量名 '@i' 已被声明.变量名在查询批处理或存储过程中必须是唯一的.

Msg 134, Level 15, State 1, Line 5 The variable name '@i' has already been declared. Variable names must be unique within a query batch or stored procedure.

这会起作用

declare @i int
set @i =5

go
declare @i int
set @i =6

Select @i

这篇关于TSQL中的GO语句是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆