--计算1-100的和 declare @int int=1; declare @total int=0; while(@int<=100) begin set @total=@total+@int; set @int=@int +1; end select @total --计算1-100偶数的和 declare @index int; declare @sum int; set @index=1; set @sum=0; while(@index<=100) begin if(@index%2=0) begin set @sum=@sum+@index end set @index=@index+1; end select @sum;