?
Solved

10777 - ISOLATION LEVEL

Posted on 2014-09-13
4
Medium Priority
?
275 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 2000 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 51

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 51

Expert Comment

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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

800 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