Hi Gurus,
I am trying to implement update target table and capture old and current values in log table.
but i am able to capture only current records, Please let me share in information to achieve.
Here is the sample table . #source is table source, table #t1 is the target table and #t1_archive is the log table .
Please let me know if you need any more information from my side. Thanks
CREATE TABLE #Source(
id INT
, somedata VARCHAR(10)
, someotherdata INT
,date_time datetime
);
INSERT INTO #Source
VALUES ( 1, 'mmm', 200,getdate() ),
( 2, 'vvv', 200 ,getdate()),
( 3, 'ccc', 500,getdate());
CREATE TABLE #t1 (
id INT
, somedata VARCHAR(10)
, someotherdata INT
,date_time datetime
);
INSERT INTO #t1
VALUES ( 1, 'aaa', 200,getdate() ),
( 2, 'bbb', 200 ,getdate()),
( 3, 'ccc', 500,getdate());
Create table #t1_archive
(
id int,
somedata_old VARCHAR(10), somedata_new VARCHAR(10)
, someotherdata_old INT,someotherdata_new int
,date_time_old datetime,date_time_new datetime
)