有一个用户表tbUsers,有好多fields,我只关注其中几个,nUserID,sUserName,sPassword;我希望有人对这数据更新,插入以及删除时能够自动记录入另一个表tbUsersActions。我使用了SQL触发器。
create trigger 用户更新触发器 on tbUsers for updateas insert into tbUsersActions(id,name,pwd,dCreateDate,action)select inserted.nUserID,inserted.sUserName,inserted.sPassword,getDate(),'update' from inserted Create trigger 用户插入触发器 on tbUsers for insertasinsert into tbUsersActions(id,name,pwd,dCreateDate,action)selectinserted.nUserID,inserted.sUserName,inserted.sPassword,getDate(),'insert' frominserted create trigger 用户删除触发器 on tbUsers for deleteasinsert into tbUsersActions(id,name,pwd,dCreateDate,action)selectdeleted.nUserID,deleted.sUserName,deleted.sPassword,getDate(),'delete' from deleted