- declare @x int,@y int,@z int
- select @x=1,@y=2,@z=3--t-sql里面用select进行赋值,而存储过程或者游标中用set进行赋值
- if @x>@y
- print 'x>y'
- else if @y>@z
- print 'y>z'
- else print 'z>y'
- declare @x int ,@y int ,@c int
- select @x=1,@y =1
- while @x<3
- begin
- print @x
- while @y<3
- begin
- select @c = 100*@x+@y
- print @c
- select @y=@y+1
- end
- select @x=@x+1
- select @y=1
- end
- --以下是waitfor的用法看起来很好玩
- waitfor delay '00:00:30'--过30秒后执行以下程序
- select * from student
- waitfor time '18:18:18'--到晚上18:18:18的时候执行以下的语句
- select * from student