Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS-SQL Lock Issues

Posted on 2002-07-09
5
Medium Priority
?
383 Views
Last Modified: 2008-01-16
I created one table with 5 row inserted and index.Now I open two
session(i.e Query analyzer) In First session I start begin transaction and updating 2
rows out of 5 rows but not giving rollback or commit transaction In second session I
am tring to select all records (i.e 5 rows{select * from object}) it is not
responding I come back to first session and apply rollback transaction.Now in second
session record is visible.

Basically I am expecting output in second session is, the two rows which are updated
with old value because it is not commited(like Oracle) and remaining 3 rows which are
not touch by any one.

What I did:- I tried to set isolation level to both session as read commited(I think
it is default but I set it) SET TRANSACTION ISOLATION LEVEL READ COMMITTED GO DBCC
USEROPTIONS GO still second session not showing any think until rollback or commit in
first session. After this I used:- exec sp_indexoption
'Object','DisAllowPageLocks',true exec sp_indexoption 'Object','AllowRowLocks',true
exec sp_tableoption 'Object','table lock on bulk load',false
again second session is not repling back.

How do I solve this problem in Sequel?




0
Comment
Question by:KanasanRamalingam
[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
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7142607
The problem in SQL Server is that you won't get the old data. Either you have to wait for the end of the transaction of session 1, or you will get the new (uncommitted) values.
By either setting this:
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
or using
SELECT * FROM yourtable (NOLOCK)
you will be able to read the rows with the current values.

CHeers
0
 

Author Comment

by:KanasanRamalingam
ID: 7142806
Hi angellll,

Thank you very much for your comments.

According to your method I'll get the dirty data from the Session 1. Which is very dangerous data.

I would like to have the committed data from the table while the transaction in session 1 is on process.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 7142834
I know that oracle supports that you get the old data from other sessions, but in SQL this is not possible. One interesting thing in this case is the READPAST hint, which should allow to skip the locked rows. If however there is a session that locks the entire table (eventually by lock escalation), you won't see any rows at all...

CHeers
0
 

Expert Comment

by:CleanupPing
ID: 9280167
KanasanRamalingam:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
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.

604 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