ScriptOut Change Tracking Tables

ScriptOut Change Tracking Tables

SELECT sys.schemas.name AS Schema_name ,
      sys.tables.name AS Table_name ,
'ALTER TABLE ' + QUOTENAME(sys.schemas.name) + '.'
+ QUOTENAME(sys.tables.name) + '
ENABLE CHANGE_TRACKING
WITH (TRACK_COLUMNS_UPDATED = ON) ' + CHAR(13) AS SQLScript
FROM sys.change_tracking_tables
JOIN sys.tables ON sys.tables.object_id = sys.change_tracking_tables.object_id
JOIN sys.schemas ON sys.schemas.schema_id = sys.tables.schema_id;

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *