PdfPrep.com

How should you complete the Transact-SQL statements?

DRAG DROP

You have a database named OnlineSales that contains a table named Customers. You plan to copy incremental changes from the Customers table to a data warehouse every hour.

You need to enable change tracking for the Customers table.

How should you complete the Transact-SQL statements? To answer, drag the appropriate Transact-SQL segments to the correct locations. Each Transact-SQL segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Answer:

Explanation:

Box 1: DATABASE [OnlineSales]

Before you can use change tracking, you must enable change tracking at the database level. The following example shows how to enable change tracking by using ALTER DATABASE.

ALTER DATABASE AdventureWorks2012

SET CHANGE_TRACKING = ON

(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)

Box 2: CHANGE_TRACKING = ON

ALTER SET CHANGE_RETENTION

Box 3: ALTER TABLE [dbo].[Customers]

Change tracking must be enabled for each table that you want tracked. When change tracking is enabled, change tracking information is maintained for all rows in the table that are affected by a DML operation.

The following example shows how to enable change tracking for a table by using ALTER TABLE.

ALTER TABLE Person.Contact

ENABLE CHANGE_TRACKING

WITH (TRACK_COLUMNS_UPDATED = ON)

Box 4: ENABLE CHANGE_TRACKING

References: https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/enable-and-disable-change-tracking-sql-server

Exit mobile version