# 求教这样的一个存储过程

yige520lgz 2005-09-19 10:07:59

...全文
183 点赞 收藏 4

4 条回复

create procedure sp_test(
@price1 money,
@Price2 money,
@Price3 money)
as
begin
declare @Break1 int,@Break2 int
declare @Count1 money,@Count1 money,Count3 money

select @Break1=Break1,@Break2=Break2 from B

update A
set
@Count1 = case when @Break1 is null then AllCount
when @Break2 is null then AllCount/@Break1
else AllCount/(@Break1*@Break2)
end,
@Count2 = case when @Break1 is null then 0
when @Break2 is null then AllCount%@Break1
else (AllCount%(@Break1*@Break2))/@Break2
end,
@Count3 = case when @Break1 is null then 0
when @Break2 is null then 0
else (AllCount%(@Break1*@Break2))%@Break2
end,
Count1 = @Count1,
Count2 = @Count2,
Count3 = @Count3,
AllMoney = @Price1*@Count1+@Price2*@Count2+@Price3*@Count3
end
go

create procedure sp_test(
@price1 money,
@Price2 money,
@Price3 money)
as
begin
declare @Break1 int,@Break2 int
declare @Count1 money,@Count1 money,Count3 money

select @Break1=Break1,@Break2=Break2 from B

update A
set
@Count1 = case when @Break1 is null then AllCount
when @Break2 is null then AllCount/@Break1
else AllCount/(@Break1*@Break2)
end,
@Count2 = case when @Break1 is null then 0
when @Break2 is null then AllCount%@Break1
else (AllCount%(@Break1*@Break2))/@Break2
end,
@Count3 = case when @Break1 is null then 0
when @Break2 is null then 0
else (AllCount%(@Break1*@Break2))/@Break2
end,
Count1 = @Count1,
Count2 = @Count2,
Count3 = @Count3,
AllMoney = @Price1*@Count1+@Price2*@Count2+@Price3*@Count3
end
go

yige520lgz 2005-09-19

yige520lgz 2005-09-19

2.7w+

MS-SQL Server 应用实例

2005-09-19 10:07