利用SQL TRIGGER來自動更新計次





CREATE TRIGGER Table_Status
on Tables
FOR Update 
AS BEGIN
SET NOCOUNT ON
DECLARE @id INT
DECLARE @cnt INT

SET @id = (select  Table_Status_Id from INSERTED)
SET @cnt = (select Table_Update_Cnt from INSERTED) 

UPDATE Tables
SET Table_Update_Cnt = @cnt + 1
where Table_Status_Id = @id
END

留言

熱門文章