寫MSSQL存儲過程 輸入參數N(1……100之間)的整數,輸出1+2+……N的和。用sql server存儲過程怎麼寫
create PROCEDURE [dbo].exp1002
AS
BEGIN
set @tsum=@n
while @n-1>=0
begin
set @n=@n-1
set @tsum=@tsum+@n
end
print '得到的結果是:'+ convert(varchar(10),@tsum)
end
-- exec exp1002 2,0