Transact-SQL 语句
当流程控制语句必须执行一个包含两条或两条以上Transact-SQL语句块时,可以使用BEGIN...END语句进行控制
use testDB; go declare @name varchar(30) declare @count int set @name='陈勇' set @count=0 set @count=(select count(*) from Students) if @count>0 begin print '还有人呢' end else begin print '一个鸟人都没有' end go
declare @sum int declare @i int set @sum=0 set @i=0 while @i>=0 begin set @i=@i+1 if @i>100 begin print '1到100之间的奇数和:'+cast(@sum as char(100)) break end if(@i%2=0) begin set @sum=@sum+@i end else begin continue end end
begin waitfor time '20:48:00' select * from Students end