I have 62 tables that were set up as system-versioned/temporal tables except the start and end time columns were set up as datetime2(0)
as shown below.
SysStartTime [datetime2](0) GENERATED ALWAYS AS ROW START NOT NULL,
SysEndTime [datetime2](0) GENERATED ALWAYS AS ROW END NOT NULL,
Because of this, we have records within the history table that appear to be duplicated because we lose the necessary precision when records were modified multiple times by our system. I haven't been able to find any documentation on modifying those two columns, but tried the following code:
ALTER TABLE SystemVersionedTable
SET (SYSTEM_VERSIONING = OFF);
ALTER TABLE SystemVersionedTable
ALTER COLUMN SysStartTime DATETIME2(7);
ALTER TABLE SystemVersionedTable
ALTER COLUMN SysEndTime DATETIME2(7);
ALTER TABLE SystemVersionedTable
SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = History.dbo_SystemVersionedTable));
However, I still get the following error:
Period column 'SysStartTime' in a system-versioned temporal table cannot be altered.
Is there a way to alter those two columns and set it to datetime2(7)
?