[MSSQL] 改變狀態Trigger

Declare @gain_id as int   
Declare @status as tinyint
Declare @user_id as nvarchar(20)
Declare @datetime as datetime

SELECT @gain_id=gain_id FROM inserted
BEGIN
INSERT INTO [dbo].[aduitLOG]
(
    [gain_id],
    [status],
    [user_id ],
    [datetime] 
)
SELECT
    [gain_id],
    [status],
    [user_id ],
    [updated] 
FROM [gain]
WHERE [gain].[gain_id] =  @gain_id

留言