How to track column value change in sql server


CREATE TRIGGER [dbo].[TGRName]
ON [dbo].[TableName]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
IF (UPDATE([ColumnName]))

INSERT INTO [TableName]([Columns]....)
Select distinct [Columns]....
from INSERTED I
INNER JOIN Deleted D ON D.Id= I.Id
WHERE I.[ColumnName] <> D.[ColumnName]

SET NOCOUNT OFF

END

Comments

Popular posts from this blog

How to Convert Word Document to PDF using C#

Sql query to get counts by quarterly and half yearly

How to upload File to Secured FTP ( SFTP ) in C#