Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
programer
Posting Yak Master
221 Posts |
Posted - 2014-06-22 : 13:49:06
|
Hi,Declare @ByName nvarchar(500)Declare @Note nvarchar(4000)SELECT Username from inserted inner join aspnet_Users on inserted.UserId=aspnet_Users.UserIdSET @ByName=(SELECT Username from inserted inner join aspnet_Users on inserted.UserId=aspnet_Users.UserId)IF UPDATE(FirstName)SET @Note='User details updated: First name 'BEGININSERT INTO tbl_Audit (UserId, Type,Date,ByName,Note) VALUES ((SELECT UserId from inserted),'1',GETDATE(),@ByName,@Note)ENDENDI have FirstName: programerNow I want to use store the last values before will updated.If updated FirstName to programer2then I need to get also programer and programer2 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-06-22 : 17:12:15
|
[code]INSERT dbo.tbl_Audit ( UserID, Type, Date, ByName, Note )SELECT i.UserID, '1', GETDATE(), i.Username, 'User details updated: First name (old) ' + d.Firstname + ' (new) ' + i.FirstNameFROM deleted AS dINNER JOIN inserted AS i ON i.UserId = d.UserId;[/code] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|
|
|