–IF ELSE
declare @x int @y int @z int
select @x = 1 @y = 2 @z=3
if @x > @y
print ‘x > y’ --打印字符串’x > y’
else if @y > @z
print ‘y > z’
else print ‘z > y’
–CASE
use pangu
update employee
set e_wage =
case
when job_level = ‟1‟ then e_wage1.08
when job_level = ‟2‟ then e_wage1.07
when job_level = ‟3‟ then e_wage1.06
else e_wage1.05
end
–WHILE CONTINUE BREAK
declare @x int @y int @c int
select @x = 1 @y=1
http://hi.baidu.com/ttcc2009
while @x < 3
begin
print @x --打印变量 x 的值
while @y < 3
begin
select @c = 100*@x + @y
print @c --打印变量 c 的值
select @y = @y + 1
end
select @x = @x + 1
select @y = 1
end
–WAITFOR
–例 等待 1 小时 2 分零 3 秒后才执行 SELECT 语句
waitfor delay ‟01:02:03‟
select * from employee
–例 等到晚上 11 点零 8 分后才执行 SELECT 语句
waitfor time ‟23:08:00‟
select * from employee