Link to home
Start Free TrialLog in
Avatar of enrique_aeo
enrique_aeo

asked on

10774 - Instead of using the hint no_lock

Hi experts,

can you give me an example in TSQL for this:
Instead of using the hint no_lock would be better to use isolation levels
read_commited_snapshot
Avatar of ste5an
ste5an
Flag of Germany image

Without more information about your context, there is no "better" method. Only a caveat: NOLOCK can result in wrong results due to phantom reads or skips on data.
Avatar of enrique_aeo
enrique_aeo

ASKER

It is advice for the optimization of queries
SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Might you help me understand the read_commited_snapshot
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
enrique_aeo, do you still need help on this question?
an example would be perfect TSQL code
Example 1 - Read Committed

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;

BEGIN TRANSACTION;

UPDATE StockPrices
SET ClosingPrice = @StockClosingPrice
WHERE StockTicker = 'AAPL'

COMMIT TRANSACTION

Open in new window


Example 2 - Nolock

SELECT *
FROM dbo.Stocks
WITH  (NOLOCK)

WHERE stockticker = 'AAPL'

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please ScottPletcher:
Might complete the example. The code ste5an friend helped me a lot, please your support. Thank You