WITH CHANGE_TRACKING_CONTEXT (Transact-SQL)
SQL Server 2012
Enables the context of a change to be specified, such as an originator ID, when data is changed. For example, when using change tracking, an application might want to differentiate between changes that were made by the application itself and changes that were made to the data outside the application.
The following example sets the change tracking context for a data change.
-- The tracked change is tagged with the specified context
DECLARE @originator_id varbinary(128);
SET @originator_id = CAST('MyApplicationID' AS varbinary(128));
WITH CHANGE_TRACKING_CONTEXT (@originator_id)
UPDATE Employees
SET Salary = 50000
WHERE EmpID = 1
-- The change now has an associated change context
SELECT c.EmpID, c.SYS_CHANGE_CONTEXT
FROM CHANGETABLE(CHANGES Employees, @last_sync_version) AS c;
