Thursday, April 16, 2020

History tracking for SQL

Add history tracking to the existing table

alter table tbl_event2
add SysStartTime datetime2 generated always as row start not null default getutcdate(),
    SysEndTime   datetime2 generated always as row end   not null default convert(datetime2, '9999-12-31 23:59:59.9999999'),
    period for system_time (SysStartTime, SysEndTime);

alter table tbl_event2
  set (system_versioning = on (HISTORY_TABLE = dbo.tbl_event2_history));

No comments:

Post a Comment

Microsoft copilot Agent

 In Copilot Chat https://m365.cloud.microsoft/chat Click on All Agents on side bar Copilot Studio Provide the details and you are agent is r...