1 declare @mynum int,@i int 2 set @i=1 3 set @mynum=0 4 while (@i<101) 5 begin 6 set @mynum = @mynum+@i 7 set @i=@i+1 8 end 9 print @mynum
ps:while循环中,begin...end相当于"{}"
时间: 2024-10-31 22:10:15
1 declare @mynum int,@i int 2 set @i=1 3 set @mynum=0 4 while (@i<101) 5 begin 6 set @mynum = @mynum+@i 7 set @i=@i+1 8 end 9 print @mynum
ps:while循环中,begin...end相当于"{}"