这两触发器比较精简,容易理解
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