第3个回答 2010-12-14
方法1
declare @i int,@n int,@tmp int
set @n=10
set @i=1
while @i<=10
begin
set @tmp=isnull(@tmp,0)+@i*(@i+1)
set @i=@i+1
end
print @tmp
方法2
declare @n int
set @n=10
select sum(number*(number+1)) from master..spt_values
where type='P' and number between 1 and @n本回答被网友采纳