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 ...
随机推荐
- python--变量,常量,用户交互
1.变量 概念:把程序运行过程中产生的中间值保存在内存,方便后面使用 命名规范: 1.字母,数字,下划线组成 2.不能用数字开头,且不能用纯数字 3.不能用python关键字 4.不要用中文 5.要有 ...
- 学习笔记|JSP教程|菜鸟教程
学习笔记|JSP教程|菜鸟教程 ------------------------------------------------------------------------------------ ...
- k_means算法的C++实现
首先画出k_means算法的流程图:
- robot framework学习笔记之十一--第三方库requests详解
一.安装 Requests 通过pip安装 pip install requests 或者,下载代码后安装: $ git clone git://github.com/kennethreitz/req ...
- 【bug】—— ios scroll 滚动穿透
BUG描述 在 ios 微信浏览器或原生浏览器中,主内容容器.content在文档流内,并且overflow-y: scroll.在其之上有一个 fixed 定位的弹出层.popUp,滚动.popUp ...
- JavaScript的几种(原型)继承
定义Foo,Bar 其中,Bar继承Foo a是Bar的实例,包含有Foo和Bar的函数和属性: function Foo(name) { this.name = name; } Foo.protot ...
- python基础知识梳理-----4基本数据类型,list ,tuple 操作 ,增删该查,以及其他功能函数
一:列表的增加 1: append() lis = ['张三','李四','王二码子','李鹏智障'] lis.append('赵武') # 这种加法是放在最后 print(lis) 输出 ...
- MyBatis学习笔记(一)创建第一个MyBatis项目
一.新建Maven项目 http://www.mybatis.org/mybatis-3/zh/index.html 该链接为MyBatis官方地址 创建MyBatis项目主要有两种办法,一种是导入j ...
- Bomb(要49)--数位dp
Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- 利用scrapy-client发布爬虫的远程服务器
一.环境准备 远程服务器必须装有scapyd,我们使用的机器必须有scrapy-client(我这里是windows),并确保这两者正常安装并启动. 二.客户端准备上传 首先进入到爬虫项目的根文件夹: ...