日期:2014-05-18 浏览次数:21049 次
--#1.
IF (1 = (CASE WHEN 1 = 1 THEN 1 ELSE 0 END)) --括号内可以是任意返回bool值的表达式, 返回值可以为true,false,null
BEGIN
PRINT 'true'
END
ELSE
BEGIN
PRINT 'false'
END
--#2.
IF (表达式)
BEGIN
GOTO ShowMessage
END
ShowMessage:
BEGIN
PRINT 'Hello, world!^^'
END
------解决方案--------------------
if....else用法
if month(getdate())<7
begin
print('上半年')
select(getdate())
end
else
begin
print('下半年')
select(getdate())
end
--while,continue,break用法
declare @i int
set @i=1
while @i<20
begin
set @i=@i+1
if @i<=19
continue
print @i
end
declare @i int
set @i=1
while @i<20
begin
if @i=19
break
print @i
set @i=@i+1
end