這兩觸發器比較精簡,容易理解
1、簡單觸發器
CREATE TRIGGER [dbo].[TriggerLog]
ON [dbo].[Users]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
Insert into dbo.[log](LogContent) select `修改前:`+Deleted.UserName+Deleted.UserRealName+`修改後:`+inserted.UserName+inserted.UserRealName from Deleted,inserted
END
2、觸發器-包含型別轉換
CREATE TRIGGER [dbo].[TriggerLog]
ON [dbo].[Base_User]
AFTER UPDATE
AS
BEGIN
— SET NOCOUNT ON added to prevent extra result sets from
— interfering with SELECT statements.
SET NOCOUNT ON;
Insert into [dbo].[Log](logName) select `修改前:` +deleted.Account+deleted.[Password]+CONVERT(varchar,deleted.Coin)+`修改後:`+inserted.Account+inserted.[Password]+CONVERT(varchar,inserted.Coin) from deleted,inserted
— CONVERT(資料型別,值)
END
GO