September 25, 2014 at 5:55 am
Hi Team,
Using (UPDLOCK, READPAST) am trying to insert records into a table with two queries.
but only first query results are storing in table.
how to user (UPDLOCK, READPAST) to execute two queries simultaniously insert into table.
Please Help.
Sesssion 1 Query 1
---------------------
DECLARE @counter INT
set @counter=1
WHILE (SELECT COUNT(*) FROM DBO.QUEUE WITH (updlock, readpast)) < 10
BEGIN
BEGIN TRAN TRAN1
INSERT INTO DBO.QUEUE
VALUES (@counter+1,'(Session 1) - Value '+ CAST(@counter+1 AS VARCHAR))
WAITFOR DELAY '00:00:05'
SELECT @counter = @counter + 1
COMMIT
END
update QUEUE1 set Sequence_id=@counter where Sequence_Name='READPAST'
Sesssion 2 Query 2
---------------------
DECLARE @counter INT
set @counter=1
WHILE (SELECT COUNT(*) FROM DBO.QUEUE WITH (updlock, readpast)) < 10
BEGIN
BEGIN TRAN TRAN1
INSERT INTO DBO.QUEUE
VALUES (@counter+1,'(Session 2) - Value '+ CAST(@counter+1 AS VARCHAR))
WAITFOR DELAY '00:00:05'
SELECT @counter = @counter + 1
COMMIT
END
update QUEUE1 set Sequence_id=@counter where Sequence_Name='READPAST'
September 25, 2014 at 6:04 am
please refer to http://stackoverflow.com/questions/7843733/confused-about-updlock-holdlock
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 25, 2014 at 8:11 am
Hi team,
The link provided in not helping..
any one please check my queries and suggest the changes.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply