Sample Header Ad - 728x90

How to exclude some column from history table in temporal table

-2 votes
2 answers
718 views
I have a same question in [Stack Overflow](https://stackoverflow.com/q/76943485/1539100) about this, But I hope to find answer here I have temporal table like below
-- Create a Temporal Table
CREATE TABLE dbo.Sample
(
  SampleId int identity(1,1) PRIMARY KEY CLUSTERED
  , SampleDate date NOT NULL
  , Data1 varchar(50)
  , Data2 varchar(50)
  -- Other fields...
  , SysStartTime datetime2 GENERATED ALWAYS AS ROW START
  , SysEndTime datetime2 GENERATED ALWAYS AS ROW END
  , PERIOD FOR SYSTEM_TIME (SysStartTime, SysEndTime)
 )
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.SampleHistory));
I want to say all of changes in Data2 does not store in HISTORY_TABLE. In another word, in very large and big tables I just need few columns for auditing so I want to exclude other columns to reduce DB size and improve performance (in some cases most frequent changes in table occur on non-auditable column) **How to do it? (in another word how to exclude to tracking changes of Data2)**
Asked by sorosh_sabz (105 rep)
Nov 2, 2023, 10:07 AM
Last activity: Apr 25, 2024, 09:56 PM