Solved

10777 - ISOLATION LEVEL

Posted on 2014-09-13
4
266 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 49

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 49

Expert Comment

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need sql in string 2 30
SCOM to SQL port 14xx failed? 1 31
help converting varchar to date 14 25
SSRS Page Header from Group Data 2 25
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

749 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