View Code
刚学了SQL,这个小程序可以锻炼SQL的基本语法。 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 begin11 set @sum = @sum+@a12 end13 end14 print @sum15 16 17 //求10的阶乘18 declare @b int19 declare @c int20 set @b = 121 set @c = 122 while(@b<=10)23 begin24 set @b = @b+125 set @c = @c*@b26 end27 print @c