alter proc sizecount
@test bigint output
as
declare @cou bigint, @noa int, @nob int, @noc int, @nod int, @noe int
select @noa=sum(filesize) from db where id<=10000
select @nob=sum(filesize) from db where id>10000 and id<=20000
select @nob=sum(filesize) from db where id>20000 and id<=30000
select @nob=sum(filesize) from db where id>30000 and id<=40000
select @nob=sum(filesize) from db where id>40000 and id<=50000
set @cou=@noa+@nob+@noc+@nod+@noe
set @test=@cou
------------------------
declare @bb bigint
exec sizecount @bb output
print @bb
@test bigint output
as
declare @cou bigint, @noa int, @nob int, @noc int, @nod int, @noe int
select @noa=sum(filesize) from db where id<=10000
select @nob=sum(filesize) from db where id>10000 and id<=20000
select @nob=sum(filesize) from db where id>20000 and id<=30000
select @nob=sum(filesize) from db where id>30000 and id<=40000
select @nob=sum(filesize) from db where id>40000 and id<=50000
set @cou=@noa+@nob+@noc+@nod+@noe
set @test=@cou
------------------------
declare @bb bigint
exec sizecount @bb output
print @bb
alter proc sizecount @cou bigint output -->輸出變量在這裡定義
as
declare @noa int, @nob int, @noc int, @nod int, @noe int
select @noa=sum(filesize) from db where id<=10000
select @nob=sum(filesize) from db where id>10000 and id<=20000
select @nob=sum(filesize) from db where id>20000 and id<=30000
select @nob=sum(filesize) from db where id>30000 and id<=40000
select @nob=sum(filesize) from db where id>40000 and id<=50000
set @cou=@noa+@nob+@noc+@nod+@noe
return @cougo------------------------
declare @bb bigint
exec sizecount @bb
print @bb