读书人

存储过程中IF.GOTO,IF.ELSE的写法解决

发布时间: 2012-03-22 17:43:57 作者: rapoo

存储过程中IF..GOTO,IF..ELSE的写法
求助SQL2000中存储过程中IF..GOTO,IF..ELSE的写法

if case @line = ''
。。。
else
。。。


类似这样的要怎么写啊

[解决办法]

SQL code
--#1.IF (1 = (CASE WHEN 1 = 1 THEN 1 ELSE 0 END)) --括号内可以是任意返回bool值的表达式, 返回值可以为true,false,nullBEGIN    PRINT 'true'ENDELSEBEGIN    PRINT 'false'END--#2.IF (表达式)BEGIN    GOTO ShowMessageENDShowMessage:BEGIN    PRINT 'Hello, world!^^'END
[解决办法]
SQL code
if....else用法if month(getdate())<7beginprint('上半年')select(getdate())endelsebeginprint('下半年')select(getdate())end--while,continue,break用法declare @i intset @i=1while @i<20begin set @i=@i+1 if @i<=19 continue print @ienddeclare @i intset @i=1while @i<20begin if @i=19 break print @i set @i=@i+1end 

读书人网 >SQL Server

热点推荐