﻿<?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 Craig Farrell  / Read Uncommitted, locks, and transactions / 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>Wed, 22 May 2013 12:38:44 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>just a wild guess n get +1 for that :)</description><pubDate>Thu, 11 Oct 2012 01:49:14 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]princa (5/7/2012)[/b][hr]Good question, it's actually the same scenario I am facing right now!!!But I still have some questions:#1 - I am using a partitioned view to union two tables, one is original table, one is backup table. So every time I will need to backup original table to backup table, and use partitioned view to union them then will return the same result as i query only original table. #2 - Then I will delete from original table and then insert all new data. While I am performing this step, eventhough I use with (nolock) on my partitioned view with select statement, it will still be locked until the insert process is done, the same behavior like Truncate. Am I doing something wrong here?[/quote]Whats the wait_type on the spid doing the select?  I'd have to reconstruct the scenario to confirm. Also, what version is the server?</description><pubDate>Tue, 08 May 2012 15:16:59 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Good question, it's actually the same scenario I am facing right now!!!But I still have some questions:#1 - I am using a partitioned view to union two tables, one is original table, one is backup table. So every time I will need to backup original table to backup table, and use partitioned view to union them then will return the same result as i query only original table. #2 - Then I will delete from original table and then insert all new data. While I am performing this step, eventhough I use with (nolock) on my partitioned view with select statement, it will still be locked until the insert process is done, the same behavior like Truncate. Am I doing something wrong here?</description><pubDate>Mon, 07 May 2012 12:49:27 GMT</pubDate><dc:creator>princa</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Straightforward question and highly detailed explanations!Thank you.</description><pubDate>Fri, 24 Feb 2012 08:06:26 GMT</pubDate><dc:creator>codebyo</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>A very very good question Craig... Thank you...</description><pubDate>Wed, 15 Feb 2012 15:15:39 GMT</pubDate><dc:creator>Jagadish Kumar Punnapu</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]mythilimca89 (2/14/2012)[/b][hr]i can't understand the question:w00t:[/quote]I assume you're joking?  If not, what in particular can't you understand?</description><pubDate>Tue, 14 Feb 2012 12:21:05 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]cengland0 (2/14/2012)[/b][hr][quote][b]Cliff Jones (2/13/2012)[/b][hr]Yes, that was the way I always did it also.  It was very fast but then you had to deal with all those pesky named constraints and foreign keys.I agree, nicely worded question and answers that required some thought.[/quote]I still do it this way, that's why I asked if there was a better way to do it -- perhaps by using the ALTER VIEW or some other method.  So everyone keeps saying that they used to populate tables this way.  Which way are you doing it now?I only do this method for my raw data sources.  The presentation layer (Not a real name for a data layer) is what has all the constraints and foreign keys.  The raw data comes from multiple sources so no contraints are at that level.  If they were, then you'd have to be extremely careful on which tables you load first and too many tables get populated simultaneously to have to worry about another problem like that.[/quote]I suspect it is still a valid and efficient way of doing it in most situations; I just don’t personally have much occasion to have to do this anymore.</description><pubDate>Tue, 14 Feb 2012 09:52:45 GMT</pubDate><dc:creator>Cliff Jones</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>i can't understand the question:w00t:</description><pubDate>Tue, 14 Feb 2012 09:24:32 GMT</pubDate><dc:creator>mythilimca89</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Very good question Craig.</description><pubDate>Tue, 14 Feb 2012 08:58:27 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Great question, thanks.</description><pubDate>Tue, 14 Feb 2012 07:48:27 GMT</pubDate><dc:creator>SQLDCH</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Great questions and really well laid out.   I prefer this type of question to one which just lists code.Thanks.</description><pubDate>Tue, 14 Feb 2012 06:29:35 GMT</pubDate><dc:creator>skanker</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>I have seen saying that using NOLOCK is good sign of the poor design.In my current work, we use NOLOCK in all SQL statements, (I know its not good)from the given scenario can anyone advice is there a way to bypass the NOLOCK usage and still get the same performance?</description><pubDate>Tue, 14 Feb 2012 03:17:14 GMT</pubDate><dc:creator>Raghavendra Mudugal</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Good question and I am feeling good now as I got it right :-)</description><pubDate>Tue, 14 Feb 2012 02:50:49 GMT</pubDate><dc:creator>mohammed moinudheen</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]Cliff Jones (2/13/2012)[/b][hr]Yes, that was the way I always did it also.  It was very fast but then you had to deal with all those pesky named constraints and foreign keys.I agree, nicely worded question and answers that required some thought.[/quote]I still do it this way, that's why I asked if there was a better way to do it -- perhaps by using the ALTER VIEW or some other method.  So everyone keeps saying that they used to populate tables this way.  Which way are you doing it now?I only do this method for my raw data sources.  The presentation layer (Not a real name for a data layer) is what has all the constraints and foreign keys.  The raw data comes from multiple sources so no contraints are at that level.  If they were, then you'd have to be extremely careful on which tables you load first and too many tables get populated simultaneously to have to worry about another problem like that.</description><pubDate>Tue, 14 Feb 2012 02:35:29 GMT</pubDate><dc:creator>cengland0</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Good Question!!Thanks you Kraig.Sandip Panihttp://sqlcommitted.com</description><pubDate>Mon, 13 Feb 2012 22:34:24 GMT</pubDate><dc:creator>sandippani</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Nice question and great discussion!</description><pubDate>Mon, 13 Feb 2012 14:47:07 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]L' Eomot Inversé (2/13/2012)[/b][hr]Great question, very well presented.In the bad old days of SQL 2000 I used to solve this sort of problem using sp_rename.Something like [code]if exists (select * from sys.objects where type = 'U' and name = 'old_FD')   drop table old_FDbegin tran --code to create new_FD and populate it wit the replacement dataexec sp_rename 'FD', 'old_FD', 'OBJECT'exec sp_rename 'new_FD','FD','OBJECT'commit tran[/code][/quote]Yes, that was the way I always did it also.  It was very fast but then you had to deal with all those pesky named constraints and foreign keys.I agree, nicely worded question and answers that required some thought.</description><pubDate>Mon, 13 Feb 2012 13:37:47 GMT</pubDate><dc:creator>Cliff Jones</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Great question, very well presented.In the bad old days of SQL 2000 I used to solve this sort of problem using sp_rename.Something like [code]if exists (select * from sys.objects where type = 'U' and name = 'old_FD')   drop table old_FDbegin tran --code to create new_FD and populate it wit the replacement dataexec sp_rename 'FD', 'old_FD', 'OBJECT'exec sp_rename 'new_FD','FD','OBJECT'commit tran[/code]The SCH_M lock is held only for the duration of the two rename operations.I did it this way because it didn't just work for tables, it worked for databases too - renaming databases is pretty quick; of course in the database, as opposed to table, case the create and populate bit was a transfer in to the server of a database created and validated elsewhere (transferred by DTS or snapshot replication or importing and restoring a backup, depending on the target server and what our access to it was like - internet between UK and 3rd world or developing countries was not always exactly brilliant) not something done in the same transaction as the renaming; some read-only (or read-only except when we wanted to replace them, to be precise) databases were better updated by that method than by updating data piecemeal - take the db describing available media directly off the QA server rather than using a script.  And losing the old data only when the current data was out of date was to allow us to roll back to the previous state if the unthinkable happened and we had made an error in one of those releases (a symptom of my paranoia).</description><pubDate>Mon, 13 Feb 2012 12:40:10 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]Sean Lange (2/13/2012)[/b][hr]Great question and excellent scenario setup. I am quite surprised that at the time I am posting there are 417 answers and 16% of them still think truncate is not logged. :w00t:[/quote]... Especially considering it's only been a week since the last discussion on it for a QotD!  :crying:</description><pubDate>Mon, 13 Feb 2012 12:25:20 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]jdamm (2/13/2012)[/b][hr]I'll add another "Great Question" - I like the questions that make you sit and think about an answer, rather than either run a snippet of code or look up a command to answer (not that we do that before answering ;-) ).J[/quote]These are never bad things, at least to me. They encourage me to do it again and I know not everyone wants to throw bricks at my head for it.  :w00t:</description><pubDate>Mon, 13 Feb 2012 12:24:27 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>To add for a moment to Paul's well answered posts, the Snapshot Isolation won't save you from the necessary locks for Truncate, but will save you from the necessary dirty reads of the original issue with DELETE FROM, which is why you went NOLOCKing in the first place.  :-)</description><pubDate>Mon, 13 Feb 2012 11:58:45 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]jdamm (2/13/2012)[/b][hr]I'll add another "Great Question" - I like the questions that make you sit and think about an answer, rather than either run a snippet of code or look up a command to answer (not that we do that before answering ;-) ).J[/quote]+1 I couldn't have said it better myself. :-D</description><pubDate>Mon, 13 Feb 2012 10:38:40 GMT</pubDate><dc:creator>Dana Medley</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>I'll add another "Great Question" - I like the questions that make you sit and think about an answer, rather than either run a snippet of code or look up a command to answer (not that we do that before answering ;-) ).J</description><pubDate>Mon, 13 Feb 2012 10:36:33 GMT</pubDate><dc:creator>jdamm</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Great question!! Thanks for it. I had to deeply analyze the lock modes and the MSDN articles in order to decide which answer was correct, and that helped me learn something new today.Thanks again.El Jerry.</description><pubDate>Mon, 13 Feb 2012 09:09:37 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>great question and discussion today - tks</description><pubDate>Mon, 13 Feb 2012 09:06:40 GMT</pubDate><dc:creator>OzYbOi d(-_-)b</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Nice straightforward question with an excellent explanation. Thanks for submitting.</description><pubDate>Mon, 13 Feb 2012 09:00:32 GMT</pubDate><dc:creator>Britt Cluff</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Nice one</description><pubDate>Mon, 13 Feb 2012 08:32:20 GMT</pubDate><dc:creator>SathishK</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Great question and excellent scenario setup. I am quite surprised that at the time I am posting there are 417 answers and 16% of them still think truncate is not logged. :w00t:</description><pubDate>Mon, 13 Feb 2012 07:39:24 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]cengland0 (2/13/2012)[/b][hr]Okay, wait a second.  If you have someone running a large query on your view, then you submit the ALTER VIEW statement, it will wait until the large query is over before it runs, right?[/quote]Right.  The ALTER VIEW (or most of the alternative strategies) have to acquire Sch-M sometime, the point is to make the time the Sch-M is held as short as possible.[quote]So, what about the queries that came after the ALTER VIEW? Wouldn't those be in queue waiting for the ALTER VIEW to complete but the ALTER VIEW hasn't started yet because it's still waiting for the select statement to complete.   So, even though it's quick, due to the way the queue works, you could still have several queries waiting to execute.[/quote]Locking used to work a bit like this (a strict FIFO model) back in SQL Server 2000.  Later versions have a much more relaxed form of FIFO where this sort of blocking does not generally occur.  New queries that are not incompatible with existing *held* locks (not just requested ones) will get to run without being blocked behind the process waiting for Sch-M.  The process needing Sch-M will get in eventually, and so long as this lock is not held for long, the users probably wouldn't even notice.</description><pubDate>Mon, 13 Feb 2012 07:26:16 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]cengland0 (2/13/2012)[/b][hr]I haven't used the SWITCH in an ALTER TABLE before but according to BOL:  If reassigning one partition's data to form a single table, the target table must already be created and it must be empty.  That seems you will still have the same problems.[/quote]The idea would be to load the new data into a separate table, then when everything is ready to flip over, truncate the existing table and SWITCH the new data in as one step.  Most of the methods require obtaining Sch-M at some stage; the point is to make the changeover almost instantaneous when everything is ready to go.  I'll respond to your question about the locks separately.</description><pubDate>Mon, 13 Feb 2012 07:20:31 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Really interesting question.  Learned something today.  Thanks.</description><pubDate>Mon, 13 Feb 2012 07:05:07 GMT</pubDate><dc:creator>Daniel Bowlin</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Really good question! thanks...</description><pubDate>Mon, 13 Feb 2012 07:03:04 GMT</pubDate><dc:creator>arthurolcot</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]SQL Kiwi (2/13/2012)[/b][hr][quote][b]cengland0 (2/13/2012)[/b][hr]What other ways can you change the entire contents of a table and still have the reports available without dirty data?[/quote]Aside from the VIEW suggestion, similar alternatives include using a SYNONYM, using ALTER TABLE SWITCH (which does not require the table to be explicitly partitioned), a local partitioned view (where only one of the underlying tables is TRUNCATEd) or sp_rename.  As Craig mentioned, yet another alternative is to use explicit keys to perform your own 'versioning'.[/quote]I haven't used the SWITCH in an ALTER TABLE before but according to BOL:  If reassigning one partition's data to form a single table, the target table must already be created and it must be empty.That seems you will still have the same problems.Regarding SYNONYM, that was an excellent suggestion.  Much better than creating a view.  However, doesn't that still put a lock on the table during the process and also wait for all previously queued SQL commands to finish before executing?</description><pubDate>Mon, 13 Feb 2012 06:45:32 GMT</pubDate><dc:creator>cengland0</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]SQL Kiwi (2/13/2012)[/b][hr][quote][b]Hugo Kornelis (2/13/2012)[/b][hr]I didn't check it, but I fully expect an ALTER VIEW statement to require an exclusive schema lock.[/quote]This is true, but it's not really a problem - the ALTER VIEW statement will eventually get the lock it needs, complete very quickly, and then release that lock.  If you don't mind how long the ALTER VIEW blocks for before succeeding, this can work well (though a deadlock might occur).[/quote]Okay, wait a second.  If you have someone running a large query on your view, then you submit the ALTER VIEW statement, it will wait until the large query is over before it runs, right?  So, what about the queries that came after the ALTER VIEW? Wouldn't those be in queue waiting for the ALTER VIEW to complete but the ALTER VIEW hasn't started yet because it's still waiting for the select statement to complete.   So, even though it's quick, due to the way the queue works, you could still have several queries waiting to execute.</description><pubDate>Mon, 13 Feb 2012 06:38:42 GMT</pubDate><dc:creator>cengland0</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]cengland0 (2/13/2012)[/b][hr]What other ways can you change the entire contents of a table and still have the reports available without dirty data?[/quote]Aside from the VIEW suggestion, similar alternatives include using a SYNONYM, using ALTER TABLE SWITCH (which does not require the table to be explicitly partitioned), a local partitioned view (where only one of the underlying tables is TRUNCATEd) or sp_rename.  As Craig mentioned, yet another alternative is to use explicit keys to perform your own 'versioning'.</description><pubDate>Mon, 13 Feb 2012 06:33:59 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]Hugo Kornelis (2/13/2012)[/b][hr]I didn't check it, but I fully expect an ALTER VIEW statement to require an exclusive schema lock.[/quote]This is true, but it's not really a problem - the ALTER VIEW statement will eventually get the lock it needs, complete very quickly, and then release that lock.  If you don't mind how long the ALTER VIEW blocks for before succeeding, this can work well (though a deadlock might occur).[quote]For the situation depicted by Craig, the best solution would probably be to use one of the SNAPSHOT isolation levels.[/quote]RCSI doesn't help here since it provides versioning at the statement level.  An RCSI query that starts after the modification starts will block waiting to acquire Sch-S.  Full snapshot isolation doesn't work either: it will also block waiting to acquire Sch-S, and if the DDL change succeeds, the query will then fail with error 3961: [i]"Snapshot isolation transaction failed in database {name} because the object accessed by the statement has been modified by a DDL statement in another concurrent transaction since the start of this transaction.  It is disallowed because the metadata is not versioned. A concurrent update to metadata can lead to inconsistency if mixed with snapshot isolation."[/i]</description><pubDate>Mon, 13 Feb 2012 06:28:07 GMT</pubDate><dc:creator>Paul White</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>I like the question.  I don't like the confilicting documentation.[quote]TRUNCATE TABLE always locks the table and page but not each row. [/quote][url]http://msdn.microsoft.com/en-us/library/ms177570.aspx[/url]Same article also mentions that this is a DDL command, so I guess the Schema  M lock is infered like most ddl commands.</description><pubDate>Mon, 13 Feb 2012 06:06:49 GMT</pubDate><dc:creator>SanDroid</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>[quote][b]cengland0 (2/13/2012)[/b][hr]I've thought of creating a view that points to the table.  Then, you can populate another table with the new information and then update the view to point to the new table.  Once all the queries are done running on the old dataset table, the old table can then be deleted.  I've never tried this so I'm curious what the experts on this forum have to say about this.  Does the view get locked if a query is running it?  Any negative sides to my proposed solution?[/quote]In this case, the view and the underlying tables will end up with a Sch-S lock.  This will negate any chance you have of either altering the view or performing a table rename while any component is using it.To completely avoid dirty data and locking issues in a case like this, you'll have to do the equivalent of a drainstop, which you can't do in SQL Server directly.  This is one of the few cases where I allow for limited Dynamic SQL, because you'll have to actually alter the call to the database, and leave a hanging transaction to 'deactivate' the older version once all the locks have cleared.Hugo is correct, the best solution in cases like this is Snapshot isolation.  It's just not always feasible, particularly if you're limited in TempDB.  This is one of those 'events' that bit me in the arse once or twice along the way and when I wrote up last week's truncation question this seemed like a good one as well, and an easy way to present it.However, to go back to the root, in most scenarios I come upon this I look into an alternate solution entirely.  Flushing a table once an hour is usually because you're reloading off an external feed.  Say, current stock ticker prices.  There are alternate ways to store this data without stepping on yourself.  On of my preferred methods is to use a version key on the new data while allowing the old to continue to exist, and a settings table to tell all views and queries which data is most current.So, you'll import new data into the same structure, assign it a key, and when that's complete you'll update the record in the settings table that indicates to all queries (via WHERE or ON clause) which set of data to use.  At the final part of the import you'll clear any data not in the last two versions (or store it, or whatever), so you don't end up with a monster archive table in your active areas.However, you don't always have time to completely rebuild an existing import process when you're looking for 'quick hits' to help optimize the system.  Swapping a DELETE FROM with no WHERE clause to a TRUNCATE TABLE clause seems an easy and effective way to reduce a good chunk of logfile load.  I find it's good to know the pitfalls of easy fixes.  ;-)</description><pubDate>Mon, 13 Feb 2012 05:56:41 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Nice one, thank youIulian</description><pubDate>Mon, 13 Feb 2012 05:04:49 GMT</pubDate><dc:creator>Iulian -207023</dc:creator></item><item><title>RE: Read Uncommitted, locks, and transactions</title><link>http://www.sqlservercentral.com/Forums/Topic1250898-2864-1.aspx</link><description>Craig - interesting question.Thanks.</description><pubDate>Mon, 13 Feb 2012 05:02:27 GMT</pubDate><dc:creator>paul s-306273</dc:creator></item></channel></rss>