Sqlserver 中必须使用分号的两种情况--【叶子】
来源:互联网 发布:建二叉树 java 编辑:程序博客网 时间:2024/04/29 11:20
用习惯了oracle后,习惯在每个语句结束后以(;)结尾。
但是在sql中有哪些情况是必须使用分号的呢?
从一些英文文献中发现:
There are two situations in which you must use the semicolon.
The first situation is where you use a Common Table Expression (CTE),
and the CTE is not the first statement in the batch.
The second is where you issue a Service Broker statement
and the Service Broker statement is not the first statement in the batch.
我们来解释一下上面的两种情况:
第一种:
declare @t table(id int)
insert into @t
select 1 union
select 3 union
select 4
;with cr as
(
select * from @t
)
select * from cr
/*
id
-----------
1
3
4
*/
这里with前面的分号是必须要有的。
第二种:
--创建主密钥:
create master key encryption by password = 'Pass.word';
--发送和接收
waitfor (
receive top(1)
@message_type = message_type_name,
@message_body = message_body,
@dialog = conversation_handle
from dbo.InventoryQueue
), timeout 2000;
为了确保分析器能知道SEND和RECEIVE正是在开始一个新命令,SEND或RECEIVE之前的命令必须以
分号(;)结束.
@【叶子】http://blog.csdn.net/maco_wang 原创作品,转贴请注明作者和出处,留此信息。
- Sqlserver 中必须使用分号的两种情况--【叶子】
- Sqlserver 中必须使用分号的两种情况--【叶子】
- Sqlserver 中必须使用分号的两种情况
- JavaScript使用分号的三种情况
- golang中自动加分号的情况
- Vue中使用vux的配置,分为两种情况:
- python中必须使用global声明全局变量的情况
- javascript中必须使用var声明局部变量的情况
- this使用的两种情况
- C++分号的使用
- 对分号的使用
- 必须使用初始化列表的几种情况
- js中必须用分号的地方——由一个题目引起的思考
- (2010-06-23)使用SQLServer中COALESCE()函数的两种方法
- C++优先级队列中,比较函数使用的两种情况:
- 必须使用锁的情况(订票系统)
- 必须使用初始化列表的情况
- escape在sqlserver中的使用--【叶子】
- Red Hat公布RHEL5.4含两个基于内核的虚拟机
- 拒绝了对对象 'address' (数据库 'auto',架构 'dbo')的 INSERT 权限
- HELLO TANHAIBO.NET
- 理想与现实
- 无线网卡故障不完全解惑(二)
- Sqlserver 中必须使用分号的两种情况--【叶子】
- 全面兼容ie6,ie7,ie8,ff的最简单的css写法
- 青春
- treter
- rtert
- HTMl颜色值
- 调整心态
- mysql 中文乱码问题
- 关于Linux与Windows