SQL Server中的流控制语句
- begin···end
该语句定义sql代码块,通常在if和while语句中使用
declare @num int ;
set @num=0; while @num<10 begin
set @num=@num+1;
print 'hello word' end
- if···else
条件判断语句,其中else是可选的
if (select sex from UserBasic where name='张三')=1
print '张三的性别是:男'
else
print '张三的性别是:女'
- while、break、continue
declare @num int ;
set @num=0; while @num<10 begin
set @num=@num+1;
print 'hello word'
if @num=2
continue
if @num=5
break
end
说明:本例输出5行 hello word
- goto label(自定义标记)
该语句用来无条件地将语句的执行顺序转到用户定义的lable处
declare @num int;
set @num=0; echo:
print 'hello word'
set @num=@num+1; while @num<10
begin
goto echo
end
- return
该语句用来无条件退出一个查询或一个过程
declare @num int ;
set @num=0; while @num<10 begin
set @num=@num+1;
print 'hello word'
if @num=5
return
end
- waitfor delay/time
该语句用来定义某天的一个时刻,执行一个语句块。waitfor delay 'time'表示要等待多长时间,waitfor time 'time'表示要等到哪个时刻执行。
示例:10秒之后输出‘hello word’
waitfor delay '00:00:10'
print 'hello word' --或 print 'hello word' waitfor delay '00:00:10'
示例:12:00钟输出‘hello word’
waitfor time '12:00:00'
print 'hello word' --或 print 'hello word' waitfor time '12:00:00'
SQL Server中的流控制语句介绍的这里。
SQL Server中的流控制语句的更多相关文章
- SQL Server中INSERT EXEC语句不能嵌套使用(转载)
问: I have three stored procedures Sp1, Sp2 and Sp3.The first one (Sp1) will execute the second one ( ...
- Sql server中内连接语句
数据库中学生表和课程表如下: 内连接sql语句: select a.studentName,a.studentAge,b.courseName from student a inner join co ...
- SQL server中的T-SQL语句
首先点击新建查询 如下图所示 创建数据库:create database 数据库名称 使用数据库:use 数据库名称 创建表:create table 表名 ( 代码 ) 输入完成执行时需选中 如果需 ...
- sql server 中使用 LIKE 语句 SqlParameter 使用
原本写的 select * from table where name like '%@searchStr%' 怎么执行都不对,想想 参数是不能加 引号的 于是改为select * from tab ...
- sql server中游标
参考:http://blog.csdn.net/luminji/article/details/5130004 利用SQL Server游标修改数据库中的数据 SQL Server中的UPDATE语句 ...
- SQL Server中【case...end】的用法
在SQL Server中 case...end 语句,一般有如下两种用法: 1.相当于C#中if...else,例: select CName,头衔=case when CLevel='A1' the ...
- SQL Server中查询数据库及表的信息语句
/* -- 本文件主要是汇总了 Microsoft SQL Server 中有关数据库与表的相关信息查询语句. -- 下面的查询语句中一般给出两种查询方法, -- A方法访问系统表,适应于SQL 20 ...
- 为什么SQL语句Where 1=1 and在SQL Server中不影响性能
最近一个朋友和我探讨关于Where 1=1 and这种形式的语句会不会影响性能.最后结论是不影响. 虽然结论正确,但对问题的认识却远远没有解决问题的根本.实际上在T-SQL语句的书写过 ...
- sql server中如何查看执行效率不高的语句
sql server中,如果想知道有哪些语句是执行效率不高的,应该如何查看呢?下面就将为您介绍sql server中如何查看执行效率不高的语句,供您参考. 在测量功能时,先以下命令清除sql se ...
随机推荐
- iOS 的各种识别码
在iOS系统中,获取设备唯一标识的方法有很多: 1. x UDID (Unique Device Identifier,已过期) 2. x OPEN UDID (已过期) 3. 广告标示符(IDFA- ...
- Android Bug BaseExpandableListAdapter, getChildView
@Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastC ...
- ceph: health_warn clock skew detected on mon的解决办法
造成集群状态health_warn:clock skew detected on mon节点的原因有两个,一个是mon节点上ntp服务器未启动,另一个是ceph设置的mon的时间偏差阈值比较小. 排查 ...
- mxonline实战15,用户中心:我的课程, 我的收藏,我的消息,登出和点击数以及收藏数
对应github地址:第15天 一. 我的课程 1. 继承usercenter-base页面 2. 编写url, view
- tf入门-池化函数 tf.nn.max_pool 的介绍
转载自此大神 http://blog.csdn.net/mao_xiao_feng/article/details/53453926 max pooling是CNN当中的最大值池化操作,其实用法和卷积 ...
- Dota2App--第三天
一.要实现的功能 1.新特性页面 1.1.是否进入新特性界面的两种情况 1)第一次安装此APP,进入新特性界面 2)不是第一次安装,但是有版本更新,进入新特性界面 1.2.具体的代码实现 //0.版本 ...
- 解决无法运行Terminator出现以下问题: File "/usr/bin/terminator"...SyntaxError: invalid syntax
在安装或者启动Terminator时可能出现这个问题: lin@Dev:~$ terminator File "/usr/bin/terminator", line 123 exc ...
- 编译原理(一)绪论概念&文法与语言
绪论概念&文法与语言 以老师PPT为标准,借鉴部分教材内容,AlvinZH学习笔记. 绪论基本概念 1. 低级语言:字位码.机器语言.汇编语言.与特定的机器有关,功效高,但使用复杂.繁琐.费时 ...
- FlowPortal-BPM——基础知识
BPM(业务流程管理) ERP:企业资源规划(Enterprise Resource Planning) HR:人力资源规划(Human Resources Planning) CRM:客户关系管理( ...
- Eclipse中的创建maven项目,无法添加src/main/java等source folder
maven无法添加src/main/java 通过Eclipse创建Java Web项目,目录结构如下: 默认是只有src/main/resources 这个source folder 按照maven ...