2014-02-15 113 views

回答

2

選擇1:你可以使用

UPDATE dbo.Crash 
SET @result = NbrOfCrash = NbrOfCrash + 1 
WHERE CrashId = 1 

只有在有上CrashId列

選項#2的PK /唯一鍵/唯一約束:否則,您可以使用

declare @updated_rows table (
NbrOfCrash int -- replace int with proper type 
); 

UPDATE dbo.Crash 
SET NbrOfCrash = NbrOfCrash + 1 
OUTPUT INSERTED.NbrOfCrash into @updated_rows 
WHERE CrashId = 1; 

select @result = NbrOfCrash/min(NbrOfCrash)/max(NbrOfCrash)/avg(NbrOfCrash) ... 
from @updated_rows; 
+0

1)正是我所需要的。非常感謝 –