I want to keep records of the history of changes, by Google I stumbled upon the Method of a single audit table ,
CREATE TABLE dbo.History ( TableName VARCHAR(50) NOT NULL ,ColumnName VARCHAR(50) NOT NULL ,RowId INT NOT NULL ,ActionType VARCHAR(50) NOT NULL ,Author INT NOT NULL ,StartDate DATETIME NOT NULL ,EndDate DATETIME NOT NULL ,IsCurrent BIT NOT NULL ) GO In this table, I lack at least two fields, the previous one ( PreviousValue ) and the current value ( CurrentValue ), the hitch is that the values will be of different types, and I don’t know what to do correctly.
For each type of value, create a separate pair, i.e. PreviousInt, CurrentInt, PreviousDecimal CurrentDecimal, etc.
Or in the appendix, before recording, cast the value to a string, and then two columns will suffice: the previous one and the current one.
Tell me how to do better, what difficulties may arise in this or that case?