<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Kalen Delaney : transaction log</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx</link><description>Tags: transaction log</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Geek City: What Triggered This Post?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2012/12/31/what-triggered-this-post.aspx</link><pubDate>Tue, 01 Jan 2013 00:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:46911</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>2</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/46911.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=46911</wfw:commentRss><description>I’d really like to get another post up onto my much neglected blog before the end of 2012. This will also start one of my New Year’s resolutions, which is to write at least one blog post a month. I’m going to tell you about a change in SQL Server that...(&lt;a href="http://sqlblog.com/blogs/kalen_delaney/archive/2012/12/31/what-triggered-this-post.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=46911" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/internals/default.aspx">internals</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/testing/default.aspx">testing</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/update-in-place/default.aspx">update-in-place</category></item><item><title>Follow-up Answers for my Australia Classes</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2012/04/04/follow-up-answers-for-my-australia-classes.aspx</link><pubDate>Wed, 04 Apr 2012 22:56:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:42698</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>2</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/42698.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=42698</wfw:commentRss><description>I was out of the country for the last two weeks of March, delivering classes in Brisbane and Sydney, which were organized by WardyIT . It was a great visit and there were 24 terrific students! As is sometimes (perhaps often?) the case, there were questions...(&lt;a href="http://sqlblog.com/blogs/kalen_delaney/archive/2012/04/04/follow-up-answers-for-my-australia-classes.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=42698" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/locking/default.aspx">locking</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/SQL+Server+2012/default.aspx">SQL Server 2012</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item><item><title>Geek City: What gets logged for SELECT INTO operations?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/03/15/what-gets-logged-for-select-into.aspx</link><pubDate>Tue, 15 Mar 2011 19:41:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34163</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>8</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/34163.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=34163</wfw:commentRss><description>Last week, I wrote about logging for index rebuild operations. I wanted to publish the result of that testing as soon as I could, because that dealt with a specific question I was trying to answer. However, I actually started out my testing by looking...(&lt;a href="http://sqlblog.com/blogs/kalen_delaney/archive/2011/03/15/what-gets-logged-for-select-into.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=34163" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/internals/default.aspx">internals</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/recovery+models/default.aspx">recovery models</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item><item><title>Geek City: What gets logged for index rebuild operations?</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2011/03/08/what-gets-logged-for-index-rebuilds.aspx</link><pubDate>Tue, 08 Mar 2011 18:54:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:33967</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>13</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/33967.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=33967</wfw:commentRss><description>This blog post was inspired by a question from a future student. Someone who was already booked for my SQL Server Internals class in June asked for some information on a current problem he was having with transaction log writes causing excessive wait...(&lt;a href="http://sqlblog.com/blogs/kalen_delaney/archive/2011/03/08/what-gets-logged-for-index-rebuilds.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=33967" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/indexes/default.aspx">indexes</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/internals/default.aspx">internals</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/recovery+models/default.aspx">recovery models</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item><item><title>Geek City: Exploring the Transaction Log Structure</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2009/12/21/exploring-the-transaction-log-structure.aspx</link><pubDate>Tue, 22 Dec 2009 00:48:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:20158</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/20158.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=20158</wfw:commentRss><description>As I mentioned last October, my PASS preconference seminar was a whole day about the transaction log . I told the attendees all kinds of things about the structure of the log, and told them about one of the best tools for exploring the structure: the...(&lt;a href="http://sqlblog.com/blogs/kalen_delaney/archive/2009/12/21/exploring-the-transaction-log-structure.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=20158" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/DBCC+LOGINFO/default.aspx">DBCC LOGINFO</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/internals/default.aspx">internals</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/metadata/default.aspx">metadata</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item><item><title>Geek City: 24 hours of SQL Server!</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2009/08/13/24-hours-of-sql-server.aspx</link><pubDate>Fri, 14 Aug 2009 01:13:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:16019</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>3</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/16019.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=16019</wfw:commentRss><description>I know, my Geek City posts are usually really technical, but I figured it’s only Geeks who are going to want a solid 24 hours of SQL Server presentations… so this post is dedicated to all the SQL Server Geeks out there! I will be presenting as part of...(&lt;a href="http://sqlblog.com/blogs/kalen_delaney/archive/2009/08/13/24-hours-of-sql-server.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=16019" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/PASS/default.aspx">PASS</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/seminars/default.aspx">seminars</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/training/default.aspx">training</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item><item><title>Geek City: When is FULL Recovery not Really FULL Recovery</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2008/11/30/when-is-full-recovery-not-really-full-recovery.aspx</link><pubDate>Sun, 30 Nov 2008 23:30:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:10205</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>12</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/10205.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=10205</wfw:commentRss><description>&lt;P&gt;You may think that having a database set to FULL Recovery Model means that your database can be fully recovered. The key word in that previous sentence is 'can'. It is possible to fully recovery a database in FULL recovery, or to restore it to an arbitrary point in time, or up to the point of a system failure, IF you have been a good DBA and you have been taking your regular backups.&lt;/P&gt;
&lt;P&gt;FULL Recovery means that all your changes to the database are fully logged, and you might think that also means that the log records stay in the log until the log records are safely stored away in a log backup. &lt;/P&gt;
&lt;P&gt;But that is not completely correct. You database can be in FULL Recovery model, but also in a state called auto-truncate mode.&lt;/P&gt;
&lt;P&gt;Most people are familiar with auto-truncation in SIMPLE Recovery, and of course that is one way to get a database into auto-truncate mode. &lt;/P&gt;
&lt;P&gt;If your database is in auto-truncate mode, the log will be truncated every time a CHECKPOINT is run against the database. Checkpoints happen at very frequent intervals, which by default is usually about every minute.&amp;nbsp; Truncation means that all log records in inactive parts of the log are marked as available to be overwritten if the log space is needed.&amp;nbsp; Truncation does not physically shrink the log file, but it can keep it from physically growing. &lt;/P&gt;
&lt;P&gt;So how do you get in auto-truncate mode? There are three ways:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;1. As a mentioned above, if you put your database into SIMPLE Recovery, it will be go into auto-truncate mode.&lt;/P&gt;
&lt;P&gt;2. If you backup the log without saving the log records, using BACKUP LOG ... WITH TRUNCATE_ONLY, no more log backups can be made, and the database is now in auto-truncate mode.&lt;/P&gt;
&lt;P&gt;3. If you have never taken a FULL backup of your database, you can never take log backups, so there is no point in keep log records available. Your database is in auto-truncate mode until the first FULL backup of the database is made.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3a. If you have never taken a FULL backup after the last time you switched from SIMPLE to either FULL or BULK_LOGGED recovery. (Thanks to Hugo)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should also be aware that taking a log backup will truncate the log, but taking a FULL database backup will not truncate the log.&lt;/P&gt;
&lt;P&gt;So how can you tell if your database is in auto-truncate mode? The &lt;EM&gt;recovery_model_desc&lt;/EM&gt; column in &lt;EM&gt;sys.databases&lt;/EM&gt; only tells you what recovery model you have set, not what behavior your database is using. To see whether a database is in auto-truncate mode, you can query a undocumented system view called &lt;EM&gt;sys.database_recovery_status&lt;/EM&gt; and look at a column called &lt;EM&gt;last_log_backup_lsn&lt;/EM&gt;. If that value is NULL, it means the database is not maintaining a sequence of log backups and it is in auto-truncate mode:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;SELECT db_name(database_id) as 'database', last_log_backup_lsn &lt;BR&gt;FROM sys.database_recovery_status&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's a whole script you can use to test this for yourself:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;-- Check for auto-truncate mode&lt;BR&gt;-- If last_log_backup_lsn is NULL, log is in auto-truncate mode &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;CREATE DATABASE FOO&lt;BR&gt;GO&lt;BR&gt;-- Check status after first creating db&lt;BR&gt;SELECT db_name(database_id) as 'database', last_log_backup_lsn &lt;BR&gt;FROM sys.database_recovery_status&lt;BR&gt;WHERE database_id = db_id('foo') &lt;BR&gt;GO&lt;BR&gt;BACKUP DATABASE foo TO disk = 'C:\foo.bak'&lt;BR&gt;GO&lt;BR&gt;-- Check status after backing up db&lt;BR&gt;SELECT db_name(database_id) AS 'database', last_log_backup_lsn &lt;BR&gt;FROM sys.database_recovery_status&lt;BR&gt;WHERE database_id = db_id('foo') &lt;BR&gt;GO&lt;BR&gt;BACKUP LOG foo WITH TRUNCATE_ONLY&lt;BR&gt;GO&lt;BR&gt;-- Check status after truncating log&lt;BR&gt;SELECT db_name(database_id) AS 'database', last_log_backup_lsn &lt;BR&gt;FROM sys.database_recovery_status&lt;BR&gt;WHERE database_id = db_id('foo') &lt;BR&gt;GO&lt;BR&gt;DROP DATABASE foo&lt;BR&gt;GO&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note that there is a change in behavior in SQL Server 2008. The BACKUP LOG ... WITH TRUNCATE_ONLY option is no longer available. If you want to force the log to be truncated (and enter auto-truncate mode) the recommended method is to change your recovery model to SIMPLE.&lt;/P&gt;
&lt;P&gt;Have fun!&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff00ff size=4&gt;~Kalen&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=10205" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item><item><title>Geek City: Reading the Transaction Log</title><link>http://sqlblog.com/blogs/kalen_delaney/archive/2008/08/23/reading-the-transaction-log.aspx</link><pubDate>Sat, 23 Aug 2008 21:07:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:8506</guid><dc:creator>Kalen Delaney</dc:creator><slash:comments>46</slash:comments><comments>http://sqlblog.com/blogs/kalen_delaney/comments/8506.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/kalen_delaney/commentrss.aspx?PostID=8506</wfw:commentRss><description>&lt;P&gt;Sorry, I'm not actually going to tell you how to read the log. I'm just going to talk about it... and whether it's a good thing to be able to do or not, or whether it's an absolutely crucial feature that MS needs to provide for us immediately, in a hotfix, if not sooner. Forget about fixing bugs, I want to read the log because I forgot to set up a trace beforehand....&lt;/P&gt;
&lt;P&gt;You may have noticed that my blogging frequency has fallen off. One or two of you also noticed that I am no longer writing a regular article each month for &lt;EM&gt;SQL Server Magazine&lt;/EM&gt;. Those two facts are related. I have cut back on non-essential activities to try to get my next book out as soon as possible.&amp;nbsp; It looks like I might even finish in time to get the book out on the shelves by early next year. Stay tuned... &lt;/P&gt;
&lt;P&gt;Since I couldn't bear to not do anything for &lt;EM&gt;SQL Server Magazine&lt;/EM&gt;, I started writing the commentary in the weekly email newsletter.&amp;nbsp; Actually, I do it every week but the fourth week of the month. If you like, you can sign up for this free newsletter &lt;A href="http://www.sqlmag.com/email/" target=_blank&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;My commentary last Thursday seemed to have rattled some cages. Before I even woke up Thursday morning, there were already two comments on the site, and someone sent me a personal email about what I wrote.&amp;nbsp; By now, there are quite a few more comments. I basically wrote about the need for a log reader tool. It wasn't deeply technical; it's just a commentary after all. You can read it &lt;A href="http://www.sqlmag.com/Articles/Index.cfm?ArticleID=100076" target=_blank&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&lt;A title=http://www.sqlmag.com/Articles/Index.cfm?ArticleID=100076 href="http://www.sqlmag.com/Articles/Index.cfm?ArticleID=100076"&gt;http://www.sqlmag.com/Articles/Index.cfm?ArticleID=100076&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But boy, did people get upset. They called me bad names... well, if 'mediocre' can be considered a bad name...&lt;/P&gt;
&lt;P&gt;So I responded as follows:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;Wow... I have never gotten so many comments so quickly about one of my articles. I must really have touched a nerve here!&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT color=#0000ff&gt;There is a difference between the actual data rows referenced by the log, and the log format. It's the log format, and giving people full details about what is in the log, that is propriatary information. There is nothing specifically bad about giving people that information. However, calling me names because I don't stand up on a soapbox and DEMAND that MS add this functionality seems a little extreme. There are plenty of other things MS could do with the product and providing a log reader tool is way down on the list. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;Yes I realize it is important to some people, but there are many other ways to get this information through tracing etc. If the developer resources are limited at MS, I would much prefer they spend their time on more important stuff. MS knows it's important that people have this information, that's why they added a great deal of additional tracing capabilities in SQL Server 2008.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT color=#0000ff&gt;Also, keep in mind that a log reader tool wouldn't help you debug problems with logic, or with bad reports due to faulty SELECTs. If your WHERE clause was written badly, a log reader tool could tell you which rows were affected, but not WHY. You'd need a tracing tool for that. Vogelm's comment that a log reader tool would help troubleshoot bad queries from 3rd party apps is not true; you need to see the statements for that, not just the affected data.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT color=#0000ff&gt;I do appreciate kbreneman's comment that the real problem is one of perception. MS should make clear that the transaction log is not an audit tool; if you want auditing, you need to set it up on your own, because you're the only one who knows what's important for you to capture.&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;(The only way to respond to comments is to write a comment of my own, and then the form insists that I rate the article I am responding to. I always feel a bit weird having to rate my own articles.) 
&lt;P&gt;Since I wrote the article, I have found out that Lumigent does have a log reader tool for SQL Server 2005, but I have heard less than stellar reviews about its ability to capture some of the more interesting datatype activities that are now possible in SQL Server 2005. And their website still doesn't list any version numbers. 
&lt;P&gt;I can't stop thinking about this, so I thought I would open up the issue to a wider audience. 
&lt;P&gt;How important do you think it is that Microsoft provide a log reader tool for us? 
&lt;P&gt;Thanks! 
&lt;P&gt;&lt;FONT color=#ff00ff size=4&gt;~Kalen&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=8506" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/Inside+SQL+Server/default.aspx">Inside SQL Server</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/SQL+Server+Magazine/default.aspx">SQL Server Magazine</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/Tools/default.aspx">Tools</category><category domain="http://sqlblog.com/blogs/kalen_delaney/archive/tags/transaction+log/default.aspx">transaction log</category></item></channel></rss>