I need to log some transactions that occur in the database. For example, a change of patient name. I know I can implement an UPDATE trigger on the Patient table and write the following code:
INSERT INTO TransactionsLogTable (cTransaction)
SELECT 'Change in patient name : OLD = ' +
Deleted.PatientName + ' NEW = ' +
INNER JOIN Deleted ON Inserted.PatientID = Deleted.PatientID AND
Inserted.PatientName <> Deleted.PatientName
but this can rapidly become a bottleneck if I want to trace like 20 fields on the same table. Using this method, I will have to perform 20 INSERT - SELECT
statements, each with a different condition.