﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Prakriti Agrawal  / LOCK / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 01:21:26 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>Sometimes, it would just be better to delete the question completely.</description><pubDate>Tue, 30 Mar 2010 08:40:08 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>I will have to remember to answer questions 2 weeks late all the time to make sure I have a well-worded question ;-)Thanks for the edits! I can't afford any more confusion than I already possess...</description><pubDate>Wed, 03 Mar 2010 10:18:24 GMT</pubDate><dc:creator>Peter Trast</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>Data modification statements typically request both shared locks and exclusive locks !!from MSDN When lock escalation occurs, the lock selected for the heap or index is strong enough to meet the requirements of the most restrictive lower level lock.Not at the same time and what about the issuing of IXWhen lock escalation occurs, the lock selected for the heap or index is strong enough to meet the requirements of the most restrictive lower level lock.For example, assume a session: Begins a transaction.Updates a table containing a clustered index.Issues a SELECT statement that references the same table.The UPDATE statement acquires these locks: Exclusive (X) locks on the updated data rows.Intent exclusive (IX) locks on the clustered index pages containing those rows.An IX lock on the clustered index and another on the table.The SELECT statement acquires these locks: Shared (S) locks on all data rows it reads, unless the row is already protected by an X lock from the UPDATE statement.Intent Share locks on all clustered index pages containing those rows, unless the page is already protected by an IX lock.No lock on the clustered index or table because they are already protected by IX locks.There are more answers than those provided.CodeOn:-P</description><pubDate>Thu, 25 Feb 2010 23:52:31 GMT</pubDate><dc:creator>Malcolm Daughtree</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>I'm glad it had been edited (twice) by the time I saw it - at least the answer is now right.  The explanation is still slighly wrong, though: the first sentence suggests that all concurrent access is prevented, but in fact read access is allowed if it uses the right "isolation" level (quote marks because I would call READ UNCOMITTED an "unisolation level").</description><pubDate>Fri, 19 Feb 2010 13:51:06 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>Thanks for having my back there Jason :cool:</description><pubDate>Thu, 18 Feb 2010 18:40:16 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Saurabh Dwivedy (2/18/2010)[/b][hr]Thanks Cirque... it sounds like I joined the party late when the question had already been modified...[/quote]You're welcome and NP.</description><pubDate>Thu, 18 Feb 2010 10:57:15 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]CirquedeSQLeil (2/18/2010)[/b][hr][quote][b]Saurabh Dwivedy (2/18/2010)[/b][hr][quote][b]Paul White (2/17/2010)[/b][hr]With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)What???!!! :w00t:I want my point back!Unless someone can post code or a reference to show that NOLOCK or READ UNCOMMITTED allows [u]modification[/u] of data protected by an exclusive lock!Grrr![/quote]With an exclusive lock, no other transactions can modify data (read operations with NOLOCK hint or read uncommitted isolation level can take place), The above choice states clearly that no other transaction can MODIFY data - which is correct; that being said, Read operations with NOLOCK hint or under read uncommitted isolation level can certain take place - REFER to the following link ----- http://www.sqlteam.com/article/introduction-to-locking-in-sql-server (exclusive lock section)Exclusive locks prevent write access to a resource by concurrent transactions , [b]I don't think there is any ambiguity in this choice - it is clear enough and correct - X Locks prevents any concurrent write access[/b]Data modification statements typically request both shared locks and exclusive locks I must admit that I was momentarily confused by the wording of this choice - I only answered it from gut feel; Typically DML operations should take an UPDATE lock; While Shared locks can be escalated to an exclusive lock when the DML kicks in, it can end up in a deadlock if another transaction (under shared lock mode) attempts to update the same data. To prevent this situation Update locks are used. Saying that Data Modification statements typically REQUEST both shared and exclusive locks does lead to an ambiguous situation. It could have been more appropriately worded.[/quote]The question originally stated (in essence) that a nolock hint could be used to modify while an exclusive lock was held.  It has been changed since.  Paul wasn't disputing that a read could happen while using the nolock hint if an exclusive lock was held - just that the wording was wrong and thus made that option incorrect.[/quote]Thanks Cirque... it sounds like I joined the party late when the question had already been modified...</description><pubDate>Thu, 18 Feb 2010 10:53:00 GMT</pubDate><dc:creator>Saurabh Dwivedy</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>Wording has been changed to make this more clear. I am awarding back points as well.</description><pubDate>Thu, 18 Feb 2010 10:52:39 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Saurabh Dwivedy (2/18/2010)[/b][hr][quote][b]Paul White (2/17/2010)[/b][hr]With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)What???!!! :w00t:I want my point back!Unless someone can post code or a reference to show that NOLOCK or READ UNCOMMITTED allows [u]modification[/u] of data protected by an exclusive lock!Grrr![/quote]With an exclusive lock, no other transactions can modify data (read operations with NOLOCK hint or read uncommitted isolation level can take place), The above choice states clearly that no other transaction can MODIFY data - which is correct; that being said, Read operations with NOLOCK hint or under read uncommitted isolation level can certain take place - REFER to the following link ----- http://www.sqlteam.com/article/introduction-to-locking-in-sql-server (exclusive lock section)Exclusive locks prevent write access to a resource by concurrent transactions , [b]I don't think there is any ambiguity in this choice - it is clear enough and correct - X Locks prevents any concurrent write access[/b]Data modification statements typically request both shared locks and exclusive locks I must admit that I was momentarily confused by the wording of this choice - I only answered it from gut feel; Typically DML operations should take an UPDATE lock; While Shared locks can be escalated to an exclusive lock when the DML kicks in, it can end up in a deadlock if another transaction (under shared lock mode) attempts to update the same data. To prevent this situation Update locks are used. Saying that Data Modification statements typically REQUEST both shared and exclusive locks does lead to an ambiguous situation. It could have been more appropriately worded.[/quote]The question originally stated (in essence) that a nolock hint could be used to modify while an exclusive lock was held.  It has been changed since.  Paul wasn't disputing that a read could happen while using the nolock hint if an exclusive lock was held - just that the wording was wrong and thus made that option incorrect.</description><pubDate>Thu, 18 Feb 2010 10:48:48 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Paul White (2/17/2010)[/b][hr]With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)What???!!! :w00t:I want my point back!Unless someone can post code or a reference to show that NOLOCK or READ UNCOMMITTED allows [u]modification[/u] of data protected by an exclusive lock!Grrr![/quote]With an exclusive lock, no other transactions can modify data (read operations with NOLOCK hint or read uncommitted isolation level can take place), The above choice states clearly that no other transaction can MODIFY data - which is correct; that being said, Read operations with NOLOCK hint or under read uncommitted isolation level can certain take place - REFER to the following link ----- http://www.sqlteam.com/article/introduction-to-locking-in-sql-server (exclusive lock section)Exclusive locks prevent write access to a resource by concurrent transactions , [b]I don't think there is any ambiguity in this choice - it is clear enough and correct - X Locks prevents any concurrent write access[/b]Data modification statements typically request both shared locks and exclusive locks I must admit that I was momentarily confused by the wording of this choice - I only answered it from gut feel; Typically DML operations should take an UPDATE lock; While Shared locks can be escalated to an exclusive lock when the DML kicks in, it can end up in a deadlock if another transaction (under shared lock mode) attempts to update the same data. To prevent this situation Update locks are used. Saying that Data Modification statements typically REQUEST both shared and exclusive locks does lead to an ambiguous situation. It could have been more appropriately worded.</description><pubDate>Thu, 18 Feb 2010 10:37:19 GMT</pubDate><dc:creator>Saurabh Dwivedy</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote]Exclusive locks prevent access to a resource by concurrent transactions[/quote]Just a small correction is needed:[quote]Exclusive locks prevent [i]write[/i] access to a resource by concurrent transactions[/quote][quote][b]vk-kirov (2/18/2010)[/b][hr]I am puzzled with the fourth answer:[quote]Data modification statements typically request both shared locks and exclusive locks[/quote]The word 'typically' is so vague. For example, typically I work with databases with the READ_COMMITTED_SNAPSHOT option turned on. Data modification statements typically don't request shared locks in this case. So I didn't select the fourth answer.[/quote]I disagree.  The majority of databases don't run under one of the row-versioning isolation levels, so use of the word 'typically' is justified.The default isolation level in SQL Server is, and has always been, READ COMMITTED.At that level of isolation, shared locks (or maybe update locks if requested) are taken by the read cursor, and escalated to exclusive locks by the write cursor if the row qualifies for modification.I understand that you don't see shared locks very often in your environment (though you must have used WITH READCOMMITTEDLOCK at some stage!) but you should still be aware of the default behaviour.Paul</description><pubDate>Thu, 18 Feb 2010 06:30:39 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Christian Buettner-167247 (2/18/2010)[/b][hr]Sorry, but option 1 is still wrong.[quote]Exclusive locks prevent access to a resource by concurrent transactions[/quote]Read access is not prevented in case of NOLOCK or READ UNCOMMITTED[/quote]Exactly. Another option is 'ALTER DATABASE xxx SET READ_COMMITTED_SNAPSHOT ON'. This, unlike NOLOCK, does not violate one of the ACID principles (isolation).I am also puzzled with the fourth answer:[quote]Data modification statements typically request both shared locks and exclusive locks[/quote]The word 'typically' is so vague. For example, typically I work with databases with the READ_COMMITTED_SNAPSHOT option turned on. Data modification statements typically don't request shared locks in this case. So I didn't select the fourth answer.</description><pubDate>Thu, 18 Feb 2010 06:15:15 GMT</pubDate><dc:creator>vk-kirov</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Christian Buettner-167247 (2/18/2010)[/b][hr][quote][b]Steve Jones - Editor (2/17/2010)[/b][hr]Edited. I'll clean up points in the am.[/quote]Sorry, but option 1 is still wrong.[quote]Exclusive locks prevent access to a resource by concurrent transactions[/quote]Read access is not prevented in case of NOLOCK or READ UNCOMMITTEDSo either this option needs to be removed from the correct options, or it needs to be reworded to show that write access to a resource is prevented and not read access.[/quote]I agree. Because of that I got wrong answer :(</description><pubDate>Thu, 18 Feb 2010 01:40:02 GMT</pubDate><dc:creator>darko IS</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Steve Jones - Editor (2/17/2010)[/b][hr]Edited. I'll clean up points in the am.[/quote]Sorry, but option 1 is still wrong.[quote]Exclusive locks prevent access to a resource by concurrent transactions[/quote]Read access is not prevented in case of NOLOCK or READ UNCOMMITTEDSo either this option needs to be removed from the correct options, or it needs to be reworded to show that write access to a resource is prevented and not read access.</description><pubDate>Thu, 18 Feb 2010 01:08:20 GMT</pubDate><dc:creator>Christian Buettner-167247</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Steve Jones - Editor (2/17/2010)[/b][hr]Edited. I'll clean up points in the am.[/quote]That was quick.</description><pubDate>Wed, 17 Feb 2010 22:27:34 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Steve Jones - Editor (2/17/2010)[/b][hr]Edited. I'll clean up points in the am.[/quote]You're my favourite SSC Editor, Steve.  Thanks.  :-D</description><pubDate>Wed, 17 Feb 2010 22:24:01 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Joy Smith San (2/17/2010)[/b][hr]I thought the below one is wrong."With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)"[/quote]I agree with you :-)It's wrong.  Not merely badly phrased...wrong.Paul</description><pubDate>Wed, 17 Feb 2010 22:23:18 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>Edited. I'll clean up points in the am.</description><pubDate>Wed, 17 Feb 2010 22:22:21 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>[quote][b]Paul White (2/17/2010)[/b][hr]With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)What???!!! :w00t:I want my point back!Unless someone can post code or a reference to show that NOLOCK or READ UNCOMMITTED allows [u]modification[/u] of data protected by an exclusive lock!Grrr![/quote]I agree with you.  I happened to find the article that discusses this and was sure that that option was just a typo and poorly written.  So I still selected it - :w00t:It should be:[quote]read operations can take place only with the use of the NOLOCK hint or read uncommitted isolation level.[/quote]This is the only part of the question that I took issue with and am glad that others saw the same thing.</description><pubDate>Wed, 17 Feb 2010 22:11:16 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>I selected the options 1 &amp; 4 and lost it.I thought the below one is wrong."With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)"Though I am microsoft certified, I give a lot wrong answers now a days...haaaaa....I need to concentrate more and more.....</description><pubDate>Wed, 17 Feb 2010 21:52:14 GMT</pubDate><dc:creator>Joy Smith San</dc:creator></item><item><title>RE: LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>With an exclusive lock, no other transactions can modify data (except for operations with NOLOCK hint or read uncommitted isolation level)What???!!! :w00t:I want my point back!Unless someone can post code or a reference to show that NOLOCK or READ UNCOMMITTED allows [u]modification[/u] of data protected by an exclusive lock!Grrr!</description><pubDate>Wed, 17 Feb 2010 21:16:52 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>LOCK</title><link>http://www.sqlservercentral.com/Forums/Topic867687-2605-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/Locking/68707/"&gt;LOCK&lt;/A&gt;[/B]</description><pubDate>Wed, 17 Feb 2010 20:15:33 GMT</pubDate><dc:creator>agrawal.prakriti</dc:creator></item></channel></rss>