Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server 2008 Linked Server and CONTEXT_INFO
    primarykey
    data
    text
    <p>I'm trying to use the SQL Server 2008 Change Tracking feature. Once the feature is enabled, you can make use of the <code>CHANGETABLE(...</code> function to query the change tracking history that is kept internally by SQL Server, e.g.:</p> <pre><code>SELECT CT.ID, CT.SYS_CHANGE_OPERATION, CT.SYS_CHANGE_COLUMNS, CT.SYS_CHANGE_CONTEXT FROM CHANGETABLE(CHANGES dbo.CONTACT,20) AS CT </code></pre> <p>where the SYS_CHANGE_CONTEXT column records the <code>CONTEXT_INFO()</code> session value. This column is useful for auditing who changed what etc.</p> <p>Some of the statements that change data are executed using four-part notation by a remote SQL Server that has the home server as a linked server e.g.:</p> <pre><code>INSERT INTO [home server].[db name].[dbo].[CONTACT](id) values(@id) </code></pre> <p>My problem is that the CONTEXT_INFO() as set on the remote server in the session executing the query does not get picked up in my home server change tracking, i.e. it doesn't look like the CONTEXT_INFO spans a distributed query. This means that the following will <strong>not</strong> result in the CONTEXT_INFO being logged on the home server change tracking. </p> <pre><code>-- I'm running on a remote server WITH CHANGE_TRACKING_CONTEXT (0x1256698477) INSERT INTO [home server].[db name].[dbo].[CONTACT](id) values(@id) </code></pre> <p>Does anyone know whether this is a limitation or if there is a way to persist/communicate CONTEXT_INFO across the distributed query?</p> <p>Thanks </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload