June 17, 2011 at 12:35 am
Hi All,
I have a doubt that if i used more than one DML command on same object
i mean if i update table and insert same table on same time what will the output? is table update or new data to be inserted at the same time?
give me reply.
June 17, 2011 at 1:28 am
Depends which runs first. SQL will take locks so that they can't run simultaneously if they affect the same data.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 17, 2011 at 1:37 am
Thanks Buddy. grt
June 18, 2011 at 4:34 am
June 18, 2011 at 9:47 am
Just to be sure... pay close attention to what Gail said. There are two inferrals to her answer. To explicity state the not-so-obvious inferral, it [font="Arial Black"]is[/font] possible for rows in the same table to be UPDATEd at the same time that INSERTs are occuring if they aren't the same rows or in the same pages or extents depending on what the locks (lock escalation, in particular) have done.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 20, 2011 at 1:04 pm
June 20, 2011 at 6:48 pm
Just a word of caution... actually, a warning of danger. 😀 Seemingly innocent table hints such as WITH(NOLOCK) and similar Transaction Isolation Level hints can produce some very incorrect data including duplication of rows when another process is updating the table. Although there's certainly the rare exception, my general advice is that if you actually need to use such hints, you've probably written a bad query or the system has a whole bunch of other bad queries in it or maybe even a bad database design. The best thing to do would to be to fix those problems instead of simply covering them up with a table hint.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply