怎么用SQL SERVER 2000语言完成“计算1+2+3+····+100的和并输出”

2024-11-26 13:41:17
推荐回答(1个)
回答1:

begin
declare @n int,@i int,@sum int;
set @n=100;
set @i=1;
set @sum=0;
while @i<=100
begin
set @sum=@sum+@i;
set @i=@i+1;
end
print @sum;
end;