Solved

10777 - ISOLATION LEVEL

Posted on 2014-09-13
4
271 Views
Last Modified: 2014-09-15
hi experts

in this code
-- Retrieve the changes between the last extracted and current versions
SET TRANSACTION ISOLATION LEVEL SNAPSHOT

DECLARE @previous_version BigInt
SELECT @previous_version = MAX(LastExtractedVersion)
FROM stg.ExtractLog
WHERE SourceName = 'Salespeople'

DECLARE @current_version BigInt
SET @current_version = CHANGE_TRACKING_CURRENT_VERSION();

SELECT  @previous_version 'Previously retrieved Version',
          @current_version 'Current version',
            CT.SalesPersonID,
        r.SalespersonName,
            r.StoreName,
            r.PostalCode,
            r.City,
            r.Region,
            r.Country
FROM
CHANGETABLE(CHANGES src.Salespeople, @previous_version) CT
INNER JOIN src.Salespeople r ON CT.SalesPersonID = r.SalesPersonID

UPDATE stg.ExtractLog
SET LastExtractedVersion = @current_version
WHERE SourceName = 'Salespeople'

SET TRANSACTION ISOLATION LEVEL READ COMMITTED
GO

why use:
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
and
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Racim BOUDJAKDJI earned 500 total points
ID: 40321477
As Row Versionning physically separates within a transaction or a database the data that is used in a SELECT from the version that is used in the INSERT/UPDATE/DELETE statements.  

The instruction makes sure that all values used in the SELECT statement are necessarily committed values ignoring all uncommitted values (at the point in time of the transaction) but adding to them an on-the-fly value coming from CDC session.  Since this feature creates overhead, the transaction put back the normal isolation mode once the UPDATE transaction is complete.

Hope this helps.
0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 40322533
By the code you posted, there's two SELECT statement followed by an UPDATE, so I think the idea is to assure that you are working with the same set of data during all process, so the need for SET TRANSACTION ISOLATION LEVEL SNAPSHOT. Also, this isolation level doesn't cause locks, since it's working with a snapshot and not with the table.

At the end SET TRANSACTION ISOLATION LEVEL READ COMMITTED to going back to the default isolation level that avoids dirty reads ( cannot read data that has been modified but not committed by other transactions).
0
 

Author Comment

by:enrique_aeo
ID: 40323037
Dear Victor, your answer is very good, unfortunately I had already qualifed question, I will have a more careful next time. Thank you
0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 40323044
No worries Enrique. The idea is to help you. Points are secondary.
Cheers
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question