View Code
1 //求200以内偶数的和 2 declare @a int 3 declare @sum int 4 set @a = 0 5 set @sum = 0 6 while(@a<=200) 7 begin 8 set @a = @a + 1 9 if(@a%2 = 0) 10 begin 11 set @sum = @sum+@a 12 end 13 end 14 print @sum 15 16 17 //求10的阶乘 18 declare @b int 19 declare @c int 20 set @b = 1 21 set @c = 1 22 while(@b<=10) 23 begin 24 set @b = @b+1 25 set @c = @c*@b 26 end 27 print @c
刚学了SQL,这个小程序可以锻炼SQL的基本语法。