我正在创建一个计算固定资产递减折旧的过程。为此,我需要在过程中根据大小写设置一个值,而大小写又基于我在Update命令中使用的表中的值。在更新表之前,我需要知道如何设置该变量。问题看起来像这样:
Create procedure Depreciation
as begin
declare @k numeric (10,2)
set @k=case
when Value From a table inside the FROM(UPDATE)>1 then 2
else 3
end
update Deprectiation Table set (Deprectiation=@k*Value)
From Tables
where conditions
谢谢。
发布于 2014-07-06 02:52:07
这是一个错误的syntax.You可以做类似下面的事情(尽管你发布的代码一点也不清楚,也不确定你想要实现什么)
Create procedure Depreciation
as
begin
declare @k numeric (10,2);
declare @value numeric (10,2);
select @value = [Value], @k = case when [Value] > 1 then 2 else 3 end
From table1 ;
update Deprectiation set Deprectiation=@k*@value where conditions;
end
发布于 2014-07-06 12:09:01
试试这个:
Create Procedure Description
AS Begin
Update DeprectiationTable
SET Deprectiation=CASE WHEN Value>1 THEN 2 ELSE 3 END * Value
From Tables
Where conditions
End
https://stackoverflow.com/questions/24589410
复制相似问题