<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Authority with Pinal Dave</title>
	<atom:link href="https://blog.sqlauthority.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sqlauthority.com/</link>
	<description>SQL Server Performance Tuning Expert</description>
	<lastBuildDate>Mon, 02 Nov 2026 01:30:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sqlauthority.com/wp-content/uploads/2016/04/pinalsmall.jpg</url>
	<title>SQL Authority with Pinal Dave</title>
	<link>https://blog.sqlauthority.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">107185061</site>	<item>
		<title>SQL Server Blocking at 2 a.m.: You Are the On-Call DBA</title>
		<link>https://blog.sqlauthority.com/2026/11/02/you-are-the-on-call-dba/</link>
					<comments>https://blog.sqlauthority.com/2026/11/02/you-are-the-on-call-dba/#respond</comments>
		
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Mon, 02 Nov 2026 01:30:00 +0000</pubDate>
				<category><![CDATA[SQL Performance]]></category>
		<category><![CDATA[SQL Activity Monitor]]></category>
		<category><![CDATA[SQL Error Messages]]></category>
		<category><![CDATA[SQL Lock]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[Transaction Log]]></category>
		<guid isPermaLink="false">https://blog.sqlauthority.com/?p=214678</guid>

					<description><![CDATA[<p>SQL Server blocking, told as a choose-your-own-path story. You are the on-call DBA. The phone has gone. The diagnosis and the kill were run in the lab on SQL Server 2025 and measured. The other branches are reasoned, and the text says which is which.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/11/02/you-are-the-on-call-dba/">SQL Server Blocking at 2 a.m.: You Are the On-Call DBA</a></p>
]]></description>
										<content:encoded><![CDATA[<div class="sqla-oncall">
<style>
.sqla-oncall .page{border-left:4px solid #333;padding:4px 0 4px 16px;margin:24px 0}
.sqla-oncall .page h2{margin:0 0 8px}
.sqla-oncall .turn{font-style:italic}
</style>
<p style="text-align: justify;"><strong>SQL Server blocking, told as a choose-your-own-path story. You are the on-call DBA. The phone has gone. The diagnosis and the kill were run in the lab on SQL Server 2025 and measured. The other branches are reasoned, and the text says which is which.</strong></p>
<p><img fetchpriority="high" decoding="async" class="wp-image-214654" style="max-width: 100%; height: auto;" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-phone.webp" alt="A paperback adventure book illustration for a SQL Server blocking incident, in the old two colour style, a phone glowing on a bedside table at night." width="1672" height="941" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-phone.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-phone-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-phone-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-phone-600x338.webp 600w" sizes="(max-width: 1672px) 100vw, 1672px" /></p>
<div class="page" id="p1">
<h2>Page 1</h2>
<p style="text-align: justify;">It&#8217;s 2:14. The alert says the order screen is timing out. You open a connection and run the query the screen runs, one order by ID.</p>
<p style="text-align: justify;">It hangs. Eight seconds later SQL Server&#8217;s lock timeout fires. It was set at eight seconds for this connection, and it hands back the error the users see.</p>
<pre>Msg 1222: Lock request time out period exceeded.
(after 8,009 ms)</pre>
<p style="text-align: justify;">A single-row read on a primary key is waiting on a lock. Something is holding it.</p>
<p class="turn" style="text-align: justify;">To find out what, turn to page 2. To restart the SQL Server service because that usually fixes things, turn to page 5.</p>
</div>
<div class="page" id="p2">
<h2>Page 2</h2>
<p style="text-align: justify;">You ask the server who&#8217;s holding what.</p>
<pre>SELECT r.session_id, r.blocking_session_id, r.wait_type, r.wait_time / 1000 AS wait_s,
       r.status, b.event_info
FROM sys.dm_exec_requests r
OUTER APPLY sys.dm_exec_input_buffer(r.session_id, NULL) b
WHERE r.session_id &lt;&gt; @@SPID;</pre>
<pre>session_id  wait_type  wait_s  status     input
52          WAITFOR    9       suspended  INSERT dbo.IncidentLog ... ('archive', 'begin ...</pre>
<p style="text-align: justify;">Session 52 isn&#8217;t blocked by anyone. It&#8217;s in a WAITFOR. It is sleeping, on purpose, in the middle of whatever it&#8217;s doing.</p>
<p style="text-align: justify;">One more query, for the transaction.</p>
<pre>SELECT s.session_id, s.program_name, DATEDIFF(SECOND, t.transaction_begin_time, SYSDATETIME()) AS open_s,
       (SELECT COUNT(*) FROM sys.dm_tran_locks l WHERE l.request_session_id = s.session_id) AS locks
FROM sys.dm_exec_sessions s
JOIN sys.dm_tran_session_transactions st ON st.session_id = s.session_id
JOIN sys.dm_tran_active_transactions t ON t.transaction_id = st.transaction_id;</pre>
<pre>session_id  program_name  open_s  locks
52          SQLCMD        11      3,367</pre>
<p style="text-align: justify;">A transaction open for eleven seconds, holding 3,367 locks, and the session is asleep. This is the archive job. It updated 400,000 rows and then paused inside its own transaction. Whoever wrote it put the pause in the wrong place.</p>
<p style="text-align: justify;">Everything that touches those rows waits for it.</p>
<p class="turn" style="text-align: justify;">To kill session 52, turn to page 3. To wait for it to finish on its own, turn to page 4.</p>
</div>
<p><img decoding="async" class="wp-image-214652" style="max-width: 100%; height: auto;" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-fork.webp" alt="Two colour adventure book illustration of a corridor splitting in two, one door marked kill and one marked wait, both closed." width="1672" height="941" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-fork.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-fork-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-fork-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-fork-600x338.webp 600w" sizes="(max-width: 1672px) 100vw, 1672px" /></p>
<div class="page" id="p3">
<h2>Page 3: you kill it</h2>
<pre>KILL 52;</pre>
<p style="text-align: justify;">The server has to undo 400,000 row updates before the locks are released. That is how it works with accelerated database recovery off, which is how this lab was set. You watch the session until it&#8217;s gone.</p>
<pre>10:14:56.586  branch KILL: killing spid 52
10:14:57.238  rollback finished, session gone after 652 ms
10:14:57.238  rows still archived after kill: 0</pre>
<p style="text-align: justify;">Six hundred and fifty-two milliseconds. The locks are gone and the order screen comes back. Every one of the 400,000 rows is back where it started.</p>
<p style="text-align: justify;">The job will need to be re-run, and whoever owns it needs to hear about the pause. But nobody is waiting any more.</p>
<p style="text-align: justify;">One thing worth knowing. I measured 652 ms and did not isolate what made it that fast. A rollback can take as long as the work it undoes. Age alone doesn&#8217;t tell you that cost. Before you kill, check the work it has done and who is stuck behind it. Check whether accelerated database recovery is on, because it changes both the rollback and when the locks come back.</p>
<p class="turn" style="text-align: justify;">To read what would have happened if you&#8217;d waited, turn to page 4. For the ending, turn to page 6.</p>
</div>
<div class="page" id="p4">
<h2>Page 4: you wait</h2>
<p style="text-align: justify;">The job was written to commit after its ninety-second pause. If nothing else goes wrong, it will.</p>
<p style="text-align: justify;">So the order screen is down for ninety seconds, minus the eleven already gone. Every user who tried in that window got the timeout on page 1.</p>
<p style="text-align: justify;">That is sometimes the right answer. Suppose the transaction had been open for two hours and the rollback would take two more. Waiting ten minutes for it to commit is the lesser harm.</p>
<p style="text-align: justify;">The rule is arithmetic. Time left until it finishes, against time to undo what it&#8217;s done. Neither number is the transaction&#8217;s age. Both come from what it has actually written, and you can only look that up if you did page 2.</p>
<p class="turn" style="text-align: justify;">For the ending, turn to page 6.</p>
</div>
<div class="page" id="p5">
<h2>Page 5: you restart the service</h2>
<p style="text-align: justify;">You didn&#8217;t look. You restarted.</p>
<p style="text-align: justify;">Every open transaction on the server rolls back, including the archive job, including anything else that was running fine. Every connection drops. Every plan leaves the cache. The buffer pool empties, and I didn&#8217;t measure what that costs the next morning.</p>
<p style="text-align: justify;">The order screen does come back, after recovery finishes, and you never find out what the problem was. So it happens again next week.</p>
<p style="text-align: justify;">I didn&#8217;t run this branch in the lab, because I didn&#8217;t need to. Everything on this page follows from what a restart is.</p>
<p class="turn" style="text-align: justify;">Go back to page 1 and choose again.</p>
</div>
<div class="page" id="p6">
<h2>Page 6: the ending</h2>
<p style="text-align: justify;">You were on call for one incident, and it had one cause: a transaction that held locks while it slept.</p>
<p style="text-align: justify;">The fix is not in your hands at 2 a.m. It&#8217;s in the job. Commit before you pause. Batch the update so each batch commits. Never hold a transaction open across a wait, a network call or a prompt.</p>
<p style="text-align: justify;">What was in your hands was the order you did things in. Look, then decide, then act. The looking took two queries and about thirty seconds.</p>
<p style="text-align: justify;">One detail from the lab I liked. The job wrote a log line saying &#8220;400,000 rows updated, holding locks&#8221; inside its own transaction. When I killed it, the line vanished with the rollback. The evidence of the problem was undone along with the problem.</p>
<p style="text-align: justify;">Write your incident log from a different connection.</p>
</div>
<p><img decoding="async" class="wp-image-214653" style="max-width: 100%; height: auto;" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-morning.webp" alt="Two colour adventure book illustration of a desk in early light, a notebook open to a page headed what happened." width="1672" height="941" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-morning.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-morning-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-morning-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/oncall-the-morning-600x338.webp 600w" sizes="(max-width: 1672px) 100vw, 1672px" /></p>
<h2>How this SQL Server blocking incident was built</h2>
<p style="text-align: justify;">A 1,200,000 row ledger table. One session updates 400,000 rows and sleeps ninety seconds inside the transaction. A second session, with an 8-second lock timeout, plays the application. A third plays you.</p>
<p style="text-align: justify;">The timings above are from the log those sessions wrote. The 652-millisecond rollback is a measurement, not a guess. The log&#8217;s clock reads 10:14 rather than 2:14. I ran the incident at ten in the morning, which is the only respectable time to rehearse one.</p>
<p style="text-align: justify;">If your shop has a job that pauses inside a transaction, <a href="https://blog.sqlauthority.com/consulting/">I&#8217;d like to meet it before 2 a.m. does</a>.</p>
<p style="text-align: justify;"><strong>An incident is not a mystery, it is a transaction somebody left open.</strong></p>
<p style="text-align: justify;">Published by <strong>Pinal Dave</strong> on <a href="https://blog.sqlauthority.com/">SQLAuthority</a>. More of my work at <a href="https://pinaldave.com/" target="_blank" rel="noopener">pinaldave.com</a>.</p>
</div>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/11/02/you-are-the-on-call-dba/">SQL Server Blocking at 2 a.m.: You Are the On-Call DBA</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sqlauthority.com/2026/11/02/you-are-the-on-call-dba/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">214678</post-id>	</item>
		<item>
		<title>20 Years of SQLAuthority: Twenty Books, One Family, and a Diary That Grew Up</title>
		<link>https://blog.sqlauthority.com/2026/11/01/20-years-of-sqlauthority/</link>
					<comments>https://blog.sqlauthority.com/2026/11/01/20-years-of-sqlauthority/#respond</comments>
		
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Sun, 01 Nov 2026 01:30:00 +0000</pubDate>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Balance Bounce Believe]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Life Lessons]]></category>
		<category><![CDATA[Memory Lane]]></category>
		<category><![CDATA[SQL Milestone]]></category>
		<guid isPermaLink="false">https://blog.sqlauthority.com/?p=217904</guid>

					<description><![CDATA[<p>20 years of SQLAuthority started with one query saved on November 1, 2006. Almost 6,000 posts later, there are nineteen books of mine and one by Shaivi on our shelf. This is the story, and a thank you to Nupur, to Shaivi and to you.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/11/01/20-years-of-sqlauthority/">20 Years of SQLAuthority: Twenty Books, One Family, and a Diary That Grew Up</a></p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;"><strong>Today marks 20 years of SQLAuthority. On November 1, 2006, I saved one SQL query on a free blog so I wouldn&#8217;t lose it again. I had no plan beyond that.</strong></p>
<p><img loading="lazy" decoding="async" class="wp-image-217897" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-1.webp" alt="The first SQL query where 20 years of SQLAuthority began, on an old wooden desk with a red sticky note that reads NOV 1, 2006" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-1.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-1-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-1-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-1-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h2>It Started Because Excel Broke My Scripts</h2>
<p style="text-align: justify;">Like every DBA, I kept a folder of scripts I used again and again. Backups, index maintenance, the query that shows how tables connect. I stored them in Excel, and Excel kept breaking the formatting. So I tried a blog, the way you try a new notebook.</p>
<p style="text-align: justify;">My first post was a query to display foreign key relationships. There was no introduction and no hello, only the query. The post was for me.</p>
<p style="text-align: justify;">I named the blog after CFAuthority, a site I loved from my ColdFusion days. The name sounded bigger than I was. I was a developer with a folder of scripts and a habit of losing them.</p>
<h2>My First Readers Were My Parents</h2>
<p style="text-align: justify;">When I started this blog, I was living outside India for work. My parents were with me then. My dad, Rajendra, and my mom, Renuka, followed this little blog more closely than I did.</p>
<p><img loading="lazy" decoding="async" class="wp-image-217901" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-5.webp" alt="Two cups of chai on a small table beside a hand-written card that reads TODAY: 5 READERS" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-5.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-5-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-5-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-5-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<p style="text-align: justify;">They checked the visitor count like a cricket score. &#8220;Today five people came to your blog.&#8221; The next day it was three. Then nine. Every number got the same happy announcement.</p>
<p style="text-align: justify;">To them it was simple and a little magical. &#8220;You write, and people read.&#8221; Nine readers felt like a full hall. Their joy was the first motivation this blog ever had, and some days it was the only one.</p>
<p style="text-align: justify;">My dad is no longer with us. Rest in peace, Papa. This twentieth anniversary belongs to you too. Mom is with us, and I wish Mom the best of health. You two were counting my readers long before anyone else did.</p>
<h2>A Stranger Found My Diary</h2>
<p style="text-align: justify;">One day an email arrived from someone I had never met. They liked my index maintenance script and wanted a small change. They had found it through Lycos.</p>
<p style="text-align: justify;">That email changed how I saw the blog. My diary was public. Anyone in the world could read it, and one person already had.</p>
<p style="text-align: justify;">That was the day SQLAuthority stopped being a notebook. Somebody out there was waiting for the next script, and I didn&#8217;t want to let them down. I still don&#8217;t.</p>
<p style="text-align: justify;">Today there are almost 6,000 posts on this blog. At the 13th anniversary I counted 4,918. I&#8217;ve stopped being surprised by the number. I haven&#8217;t stopped being grateful for the people behind it.</p>
<h2>Six Days Old, and Already in a Sentence</h2>
<p style="text-align: justify;">On September 1, 2009, Nupur and I became parents. Shaivi arrived at 7:03 in the morning, and our lives were rewritten in one breath.</p>
<p><img loading="lazy" decoding="async" class="wp-image-217898" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-2.webp" alt="A tiny knitted baby cap resting on a notebook of crossed out names beside a stamp that reads SEPT 1, 2009" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-2.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-2-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-2-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-2-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<p style="text-align: justify;">We had shortlisted nearly 100 names. My mom, Renuka, found the one we chose, in our old scriptures.</p>
<p style="text-align: justify;">Six days later I wrote about it on this blog, in between posts about SQL Server. In that post, <strong><a href="https://blog.sqlauthority.com/2009/09/08/sqlauthority-news-shaivi-dave-baby-sqlauthority/">Baby SQLAuthority</a></strong>, I added one sentence I hadn&#8217;t planned to write. It read: &#8220;I am sure that my daughter Shaivi will make me proud one day.&#8221;</p>
<p style="text-align: justify;">I didn&#8217;t know then that a sentence can wait. That one waited for years.</p>
<h2>The Youngest Speaker in the Room</h2>
<p style="text-align: justify;">On April 20, 2013, the Bangalore SQL user group held a Women in SQL day. More than a hundred people came. The organizers wanted a surprise for the end: the youngest SQL speaker anyone had seen.</p>
<p style="text-align: justify;">Shaivi was three years and seven months old. We stood on that stage together, and Shaivi said a few words about SQL Server to a room of engineers. I wrote about it the next day in <strong><a href="https://blog.sqlauthority.com/2013/04/21/women-in-sql-the-youngest-sql-speaker-at-sql-bangalore/">Youngest SQL Speaker</a></strong>.</p>
<p style="text-align: justify;">I have spoken at conferences in fourteen countries. In one year alone I presented at eighteen international events. None of those stages felt like that one.</p>
<p><img loading="lazy" decoding="async" class="wp-image-217899" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-3.webp" alt="Young Shaivi speaks about SQL onstage to a full conference room while two proud parents watch from behind" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-3.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-3-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-3-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-3-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h2>Nupur, and the Hours Behind Every Post</h2>
<p style="text-align: justify;">Almost 6,000 posts means almost 6,000 drafts that Nupur, my wife, read before you did. I was the one typing, but I did not bring this blog through twenty years by myself.</p>
<p style="text-align: justify;">Nupur edits every single post I publish. She catches the typo I can no longer see and the sentence that made sense in my head but not on the page. When I think a post is finished, she gives it another careful read.</p>
<p><img loading="lazy" decoding="async" class="wp-image-217905" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-6-overhead.webp" alt="An overhead painting of Nupur's hands marking a blog draft in red ink beside stacks of pages and a cup of tea" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-6-overhead.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-6-overhead-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-6-overhead-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-6-overhead-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<p style="text-align: justify;">Her name is not in the byline, yet her work is in the version you read. Editing can be invisible when it is done well. The hours she gave this blog deserve to be seen. Nupur, thank you for every page you read, especially when I was ready to call it done.</p>
<h2>The Twentieth Book Has Shaivi&#8217;s Name on It</h2>
<p style="text-align: justify;">Over these twenty years I wrote nineteen books. I know what it takes to finish one: the work at the desk and the patience of the people waiting beyond it.</p>
<p style="text-align: justify;">Shaivi wanted to help our family reach twenty books for the twentieth year of SQLAuthority. She wrote <strong><a href="https://blog.sqlauthority.com/2026/06/01/from-baby-sqlauthority-to-author-shaivi-you-made-us-proud/">Balance, Bounce &amp; Believe: A Practical Guide for Young Gymnasts</a></strong>, drawing on her life as a gymnast. When I saw her name on the cover, I thought of the six-day-old baby I had introduced to you on this blog.</p>
<p><img loading="lazy" decoding="async" class="wp-image-217900" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-4.webp" alt="A painting of Shaivi in glasses writing in the gymnastics gym beside a pink book, with nineteen of Pinal&#039;s books on a shelf" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-4.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-4-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-4-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-4-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<p style="text-align: justify;">Nineteen books by me. The twentieth is hers. Twenty books in our family, in the twentieth year of this blog. I could have counted posts or readers today. This is the number that stopped me.</p>
<p style="text-align: justify;">I wrote in 2009 that Shaivi would make me proud. She had done that long before she became an author. Still, opening a book she made felt different. For a moment, I was simply her reader.</p>
<h2>Brent Ozar: Because You Are, I Am</h2>
<p style="text-align: justify;">There is a story from the Mahabharata I grew up with. Dronacharya was the greatest archery teacher of the age, and taught only the princes of the royal court. A young archer from the forest, Eklavya, came to learn and was turned away.</p>
<p style="text-align: justify;">Eklavya went back into the forest and shaped an image of Drona out of clay. Every day, Eklavya practiced in front of that clay teacher, as if the real one were watching. Years later, Eklavya had become one of the finest archers alive, taught by a teacher who never knew.</p>
<p style="text-align: justify;">I am Eklavya in this story, and <strong><a target="_blank" rel="nofollow noopener" href="https://www.brentozar.com/">Brent Ozar</a></strong> is my Drona. I learned from Brent&#8217;s posts and Office Hours for years, from far away, long before we met.</p>
<p><img loading="lazy" decoding="async" class="wp-image-217903" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-7.webp" alt="Pinal and Brent seen from behind walking toward the layered hills of Red Rock Canyon, Brent pointing ahead" width="1672" height="941" style="max-width:100%;height:auto;display:block;margin:1.2em auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-7.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-7-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-7-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/20-years-of-sqlauthority-7-1536x864.webp 1536w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<p style="text-align: justify;">The story ends with Drona asking Eklavya for a right thumb as the teacher&#8217;s fee. Eklavya gave it without a word. Brent never asked me for anything. Brent only kept giving.</p>
<p style="text-align: justify;">Some friendships show up in the comments long before they show up in life. Brent left a first comment here in 2008. It was a practical warning about msdb history growing too large.</p>
<p style="text-align: justify;">On September 1, 2009, I posted that our baby had arrived. Brent was there that day too: &#8220;WOOHOO! Congratulations, sir!&#8221; In June this year, on Shaivi&#8217;s author post, Brent wrote again: &#8220;Congratulations to all of you!&#8221;</p>
<p style="text-align: justify;">In between, Brent called me a friend in 2011 and a natural presenter in 2017. Brent cheered my anniversaries and wrote that Nupur and I put real effort into this work. In 2023 I was a surprise guest on <strong><a href="https://blog.sqlauthority.com/2023/10/05/office-hours-with-special-host-brent-ozar/">Brent&#8217;s Office Hours</a></strong>. For years Brent has been my mentor in this field.</p>
<p style="text-align: justify;">In Hindi we say &#8220;tu hai to main hoon.&#8221; Because you are, I am. Brent, this blog is here partly because you are. Thank you.</p>
<h2>What 20 Years of SQLAuthority Taught Me</h2>
<p style="text-align: justify;">People ask me for the secret. There isn&#8217;t one. I wrote the next post, then the next one, on the easy days and the hard ones.</p>
<p style="text-align: justify;">Consistency looks like discipline from the outside. From the inside it looks like people: the reader waiting for an answer, and the family making room for it.</p>
<p style="text-align: justify;">I&#8217;ve made mistakes here too. Some of my old answers were wrong, and readers told me. This month I went back and corrected a few of my replies from 2007. Twenty years late is still better than never.</p>
<p style="text-align: justify;">If you have a folder of scripts you keep losing, start a blog. Don&#8217;t wait until you feel ready. I wasn&#8217;t.</p>
<h2>Thank You</h2>
<p style="text-align: justify;">To every reader who asked a question, left a comment or found a mistake: thank you. Twenty years ago this was one query saved in a hurry. You turned it into a place people come back to.</p>
<p style="text-align: justify;">To Mom, and to Papa in loving memory: you counted my first readers when there were only five. Thank you for believing it mattered.</p>
<p style="text-align: justify;">To Nupur, for reading every draft and giving this work your time again and again: thank you. To Shaivi, for making the twentieth book entirely your own: I am so proud of you.</p>
<p style="text-align: justify;">Tomorrow there will be another post. There usually is.</p>
<p><strong>Twenty years of SQLAuthority is not a count of posts, it is the people who made each one possible.</strong></p>
<p>Published by <strong>Pinal Dave</strong> on <a href="https://blog.sqlauthority.com/">SQLAuthority</a>. More of my work at <a href="https://pinaldave.com/" target="_blank" rel="noopener">pinaldave.com</a>.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/11/01/20-years-of-sqlauthority/">20 Years of SQLAuthority: Twenty Books, One Family, and a Diary That Grew Up</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sqlauthority.com/2026/11/01/20-years-of-sqlauthority/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">217904</post-id>	</item>
		<item>
		<title>AI Read the Procedure Nobody Dares to Touch</title>
		<link>https://blog.sqlauthority.com/2026/10/31/ai-read-the-procedure-nobody-touches/</link>
					<comments>https://blog.sqlauthority.com/2026/10/31/ai-read-the-procedure-nobody-touches/#respond</comments>
		
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Sat, 31 Oct 2026 01:30:00 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[SQL Documentation]]></category>
		<category><![CDATA[SQL Humor]]></category>
		<category><![CDATA[SQL Stored Procedure]]></category>
		<guid isPermaLink="false">https://blog.sqlauthority.com/?p=215060</guid>

					<description><![CDATA[<p>AI read the procedure that everybody walks past. Nine hundred lines, no comments, one very old warning at the top.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/10/31/ai-read-the-procedure-nobody-touches/">AI Read the Procedure Nobody Dares to Touch</a></p>
]]></description>
										<content:encoded><![CDATA[<p><strong>AI read the procedure that everybody walks past. Nine hundred lines, no comments, one very old warning at the top.</strong></p>
<p><picture><source media="(max-width: 600px)" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/06-ai-read-the-procedure-nobody-touches-titled-tall.webp"><img loading="lazy" decoding="async" class="wp-image-215373" width="1500" height="558" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/06-ai-read-the-procedure-nobody-touches-titled.webp" alt="Three panel Halloween cartoon. Sam says nobody has opened this procedure since 2011. The red bird says it read the whole thing and the office lights flicker. The bird reports a comment saying do not fix, signed by the bird, yesterday." style="max-width:100%;height:auto;" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/06-ai-read-the-procedure-nobody-touches-titled.webp 1500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/06-ai-read-the-procedure-nobody-touches-titled-500x186.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/06-ai-read-the-procedure-nobody-touches-titled-800x298.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/06-ai-read-the-procedure-nobody-touches-titled-600x223.webp 600w" sizes="auto, (max-width: 1500px) 100vw, 1500px" /></picture></p>
<p><em>Cardinal Rules. A Saturday cartoon about AI and databases.</em></p>
<p>Every shop has one. Nine hundred lines, no comments, a name like usp_ProcessFinal2, and a quiet agreement that nobody opens it during month end.</p>
<p>Cardinal can read it in a second, and this is the honest good news. A model is genuinely excellent at the mechanical part. It will tell you what the procedure touches, which tables it writes, where the cursor is, that the same table gets updated three separate times, and that one branch has been unreachable since a parameter default changed.</p>
<p>That is real work, and it used to take a careful afternoon. Ask for it. It is one of the best uses of AI in database work right now.</p>
<p>Then comes the part where the lights flicker. There is a clause that only fires on Tuesdays. Cardinal can describe exactly what it does and has absolutely no idea why it exists. The why was a promise made to a customer in 2011 by somebody who left in 2014. It is not in the code. It was never in the code.</p>
<p>So the procedure is not haunted by its logic. It is haunted by a decision nobody wrote down. Read the code with the machine, then go and find the one person who remembers the Tuesday, and this time write it in a comment with a date and a name on it.</p>
<h2>Cardinal Rule</h2>
<blockquote>
<p><strong>Code nobody understands is not an asset, it is a haunting.</strong></p>
</blockquote>
<p>The machine reads what the code does. Only people remember why.</p>
<p><em>Cardinal has refused to open the procedure again until November. On the desk this season: <strong>AI: Nobody&#8217;s in There. But we&#8217;re still in here.</strong> (<a target="_blank" rel="nofollow noopener" href="https://www.amazon.com/dp/B0H4T6W21S">on Amazon</a>) and <a href="https://blog.sqlauthority.com/2026/09/24/ai-interview-questions-book/">100 AI Interview Questions and Answers for Data Professionals</a> (<a target="_blank" rel="nofollow noopener" href="https://www.amazon.com/dp/B0HKK9VQ8Z">Kindle</a>, also on <a target="_blank" rel="nofollow noopener" href="https://www.amazon.in/dp/B0HKK9VQ8Z">Amazon.in</a>, <a target="_blank" rel="nofollow noopener" href="https://www.amazon.com/dp/B0HKN42ZDG">paperback</a> and <a target="_blank" rel="nofollow noopener" href="https://www.amazon.com/dp/B0HKL1PK8Q">audiobook</a>).</em></p>
<p>Next Saturday, the VP announces that the AI says the backups are fine.</p>
<p><strong>Ask the machine what the code does. Ask a person why it does it.</strong></p>
<p>Published by <strong>Pinal Dave</strong> on <a href="https://blog.sqlauthority.com/">SQLAuthority</a>. More of my work at <a href="https://pinaldave.com/" target="_blank" rel="noopener">pinaldave.com</a>.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/10/31/ai-read-the-procedure-nobody-touches/">AI Read the Procedure Nobody Dares to Touch</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sqlauthority.com/2026/10/31/ai-read-the-procedure-nobody-touches/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">215060</post-id>	</item>
		<item>
		<title>Find the Query That Ran at 3 a.m.: A Wanted Poster</title>
		<link>https://blog.sqlauthority.com/2026/10/30/wanted-the-3am-query/</link>
					<comments>https://blog.sqlauthority.com/2026/10/30/wanted-the-3am-query/#respond</comments>
		
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Fri, 30 Oct 2026 01:30:00 +0000</pubDate>
				<category><![CDATA[SQL Performance]]></category>
		<category><![CDATA[Execution Plan]]></category>
		<category><![CDATA[Query Store]]></category>
		<category><![CDATA[SQL Monitoring]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<guid isPermaLink="false">https://blog.sqlauthority.com/?p=214677</guid>

					<description><![CDATA[<p>How to find the query that ran at 3 a.m. after the fact. It uses nothing but what SQL Server 2025 keeps on its own. I planted a culprit, gave it eight disguises and buried it in four hundred innocent lookups. Then I tracked it down with Query Store. This is the poster.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/10/30/wanted-the-3am-query/">Find the Query That Ran at 3 a.m.: A Wanted Poster</a></p>
]]></description>
										<content:encoded><![CDATA[<div class="sqla-wanted">
<style>
.sqla-wanted .poster{border:6px double #4a3a1a;background:#f3e9cf;padding:22px 26px;margin:20px auto;max-width:560px;font-family:Georgia,serif;text-align:center;color:#2b2013}
.sqla-wanted .poster .w{font-size:2.6em;font-weight:900;letter-spacing:.12em;margin:0}
.sqla-wanted .poster .sub{font-size:.95em;letter-spacing:.2em;margin:0 0 14px}
.sqla-wanted .poster .line{border-top:2px solid #4a3a1a;margin:12px 0}
.sqla-wanted .poster dl{text-align:left;display:grid;grid-template-columns:150px 1fr;gap:4px 12px;font-size:.95em}
.sqla-wanted .poster dt{font-weight:bold}
.sqla-wanted .poster dd{margin:0}
.sqla-wanted .poster .reward{font-size:1.3em;font-weight:900;margin:12px 0 0}
</style>
<p style="text-align: justify;"><strong>How to find the query that ran at 3 a.m. after the fact. It uses nothing but what SQL Server 2025 keeps on its own. I planted a culprit, gave it eight disguises and buried it in four hundred innocent lookups. Then I tracked it down with Query Store. This is the poster.</strong></p>
<div class="poster">
<p class="w" style="text-align: justify;">WANTED</p>
<p class="sub" style="text-align: justify;">FOR READING 2,500,000 ROWS TO COUNT THEM</p>
<div class="line"></div>
<dl>
<dt>Description</dt>
<dd>A COUNT_BIG over dbo.Orders_S60, filtered on Amount and Status, neither of which has an index. Travels under a different literal each time, so no two sightings look alike.</dd>
<dt>Sightings</dt>
<dd>8, between 09:35:00 and 09:35:03 UTC.</dd>
<dt>Cost per sighting</dt>
<dd>41,823 logical reads. 334,584 in total.</dd>
<dt>Known accomplice</dt>
<dd>PK_Orders_S60, the clustered index, scanned end to end. 2,500,000 rows read per sighting.</dd>
<dt>Last seen</dt>
<dd>09:35:03 UTC, in the 09:00 to 10:00 interval.</dd>
<dt>Distinguishing mark</dt>
<dd>Query hash 0x1E34C17E155296A7. The literal changes. The hash does not.</dd>
</dl>
<div class="line"></div>
<p class="reward" style="text-align: justify;">REWARD: one nonclustered index on (Status, Amount)</p>
</div>
<p style="text-align: justify;">Here&#8217;s how the poster was made.</p>
<h2>The crime: one query that ran at 3 a.m.</h2>
<p style="text-align: justify;">I cleared Query Store so the only history was what this test made. Then two hundred innocent lookups, one customer each, a few reads apiece.</p>
<p style="text-align: justify;">Then the culprit, eight times, with a different amount in the WHERE clause each time. It looked like eight separate ad hoc statements. Then two hundred more innocents on top, to bury it.</p>
<p style="text-align: justify;">Then I flushed Query Store to disk and started the investigation cold. As if I&#8217;d been handed the alert a minute ago.</p>
<h2>Step one: who did the most reads?</h2>
<p style="text-align: justify;">The first query any investigator runs. Everything Query Store saw, sorted by total reads.</p>
<pre>DECLARE @from DATETIME2(3) = DATEADD(HOUR, -1, SYSUTCDATETIME()),
        @to   DATETIME2(3) = SYSUTCDATETIME();

SELECT TOP (5) q.query_id, LEFT(qt.query_sql_text, 52) AS query_text,
       SUM(rs.count_executions) AS execs,
       SUM(rs.avg_logical_io_reads * rs.count_executions)
         / SUM(rs.count_executions) AS avg_reads,
       SUM(rs.avg_logical_io_reads * rs.count_executions) AS total_reads,
       MAX(rs.last_execution_time) AS last_seen
FROM sys.query_store_query q
JOIN sys.query_store_query_text qt ON qt.query_text_id = q.query_text_id
JOIN sys.query_store_plan p ON p.query_id = q.query_id
JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id
WHERE rs.last_execution_time &gt;= @from
  AND rs.first_execution_time &lt;= @to
GROUP BY q.query_id, LEFT(qt.query_sql_text, 52)
ORDER BY total_reads DESC;</pre>
<pre>query_id  query_text                                     execs  avg_reads  total_reads  last_seen
7         (@x bigint)SELECT @x = COUNT_BIG(*) FROM dbo...  1      41,823     41,823       09:35:02
8         (@x bigint)SELECT @x = COUNT_BIG(*) FROM dbo...  1      41,823     41,823       09:35:02
6         (@x bigint)SELECT @x = COUNT_BIG(*) FROM dbo...  1      41,823     41,823       09:35:01
5         (@x bigint)SELECT @x = COUNT_BIG(*) FROM dbo...  1      41,823     41,823       09:35:01
3         (@x bigint)SELECT @x = COUNT_BIG(*) FROM dbo...  1      41,823     41,823       09:35:00</pre>
<p style="text-align: justify;">Five suspects at the top, each seen once. They look like five different people. That&#8217;s the disguise working.</p>
<p style="text-align: justify;">Two things about this query, and an earlier draft of this post got both wrong.</p>
<p style="text-align: justify;"><strong>Aggregate before you rank.</strong> One runtime stats row is one plan in one interval. Rank the raw rows and the arithmetic goes wrong. A heavy query that ran all week can sit below one that ran once. Group by the query first, then sum.</p>
<p style="text-align: justify;"><strong>Declare the window once and keep it.</strong> My earlier version filtered by interval in step one and then dropped the filter in steps two and three. In a freshly cleared lab that gives the right answer. In a production Query Store holding weeks of history it would not.</p>
<h2>Step two: take off the disguise</h2>
<p style="text-align: justify;">The query hash is computed from the statement shape with the literals stripped out. Eight statements with different amounts share one hash.</p>
<pre>SELECT TOP (3) q.query_hash, COUNT(DISTINCT q.query_id) AS distinct_texts,
       SUM(rs.count_executions) AS execs,
       SUM(rs.avg_logical_io_reads * rs.count_executions) AS total_reads
FROM sys.query_store_query q
JOIN sys.query_store_query_text qt ON qt.query_text_id = q.query_text_id
JOIN sys.query_store_plan p ON p.query_id = q.query_id
JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id
WHERE rs.last_execution_time &gt;= @from
  AND rs.first_execution_time &lt;= @to
GROUP BY q.query_hash
ORDER BY total_reads DESC;</pre>
<pre>query_hash          distinct_texts  execs  total_reads
0x1E34C17E155296A7  8               8      334,584
0xB3D890533C39CB7C  1               394    3,819</pre>
<p style="text-align: justify;">One suspect, eight disguises, 334,584 reads. I issued four hundred innocent lookups and Query Store recorded 394 executions of them, 3,819 reads in total. The culprit did 88 times the reads of everyone else combined.</p>
<p style="text-align: justify;">Same window as step one. That is the whole point of declaring it once.</p>
<p><img loading="lazy" decoding="async" class="wp-image-214666" style="max-width: 100%; height: auto;" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-hash.webp" alt="Old west poster illustration of the query that ran at 3 a.m. as eight slightly different outlaw sketches, faces hidden under hat brims, each with the same distinctive tear on the sleeve, and a pencil circle drawn around that tear." width="1672" height="941" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-hash.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-hash-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-hash-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-hash-600x338.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h2>Step three: the accomplice</h2>
<p style="text-align: justify;">Query Store keeps the plan. The plan names what it touched.</p>
<pre>;WITH inwindow AS (
    SELECT q.query_hash, p.plan_id, p.query_plan,
           p.is_parallel_plan, p.last_execution_time,
           rs.avg_logical_io_reads * rs.count_executions AS reads
    FROM sys.query_store_query q
    JOIN sys.query_store_query_text qt ON qt.query_text_id = q.query_text_id
    JOIN sys.query_store_plan p ON p.query_id = q.query_id
    JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id
    WHERE rs.last_execution_time &gt;= @from
      AND rs.first_execution_time &lt;= @to
), top_hash AS (
    SELECT TOP (1) query_hash FROM inwindow
    GROUP BY query_hash ORDER BY SUM(reads) DESC
), worst_plan AS (
    SELECT TOP (1) plan_id FROM inwindow
    WHERE query_hash = (SELECT query_hash FROM top_hash)
    GROUP BY plan_id ORDER BY SUM(reads) DESC
)
SELECT TOP (1) w.plan_id, w.is_parallel_plan,
       CAST(w.query_plan AS XML).value('count(//*[local-name()="RelOp"])', 'int') AS operators,
       CAST(w.query_plan AS XML).value('(//*[local-name()="RelOp"][.//*[local-name()="Object"]]/@PhysicalOp)[last()]', 'varchar(40)') AS access,
       CAST(w.query_plan AS XML).value('(//*[local-name()="Object"]/@Table)[1]', 'varchar(40)') AS accomplice_table,
       CAST(w.query_plan AS XML).value('(//*[local-name()="Object"]/@Index)[1]', 'varchar(40)') AS accomplice_index,
       CAST(w.query_plan AS XML).value('(//*[local-name()="RelOp"][.//*[local-name()="Object"]]/@EstimatedRowsRead)[last()]', 'float') AS est_rows_read
FROM inwindow w WHERE w.plan_id = (SELECT plan_id FROM worst_plan);</pre>
<pre>plan_id  is_parallel  operators  access                 accomplice_table  accomplice_index  est_rows_read
3        0            2          Clustered Index Scan   [Orders_S60]      [PK_Orders_S60]   2,500,000</pre>
<p style="text-align: justify;">Two operators. A scan of the clustered index, reading every one of 2,500,000 rows, and an aggregate on top. There&#8217;s no index on Status or Amount, so there&#8217;s nowhere else to go.</p>
<p style="text-align: justify;">Two details worth copying. Rank that hash&#8217;s plans by the reads they did, not by which ran last. The same query shape ran again after I built the index. That newer plan is innocent. And take the innermost operator that touches the object. The first one in the plan is the aggregate sitting above it.</p>
<p style="text-align: justify;">That&#8217;s the reward on the poster, and I paid it. With a 48 MB index on (Status, Amount), the same count went from 41,823 reads to 4,886. It ran as a seek on the new index.</p>
<h2>Step four: last seen</h2>
<pre>SELECT i.start_time, i.end_time, SUM(rs.count_executions) AS execs,
       SUM(rs.avg_logical_io_reads * rs.count_executions) AS reads,
       MIN(rs.first_execution_time) AS first_seen, MAX(rs.last_execution_time) AS last_seen
FROM sys.query_store_query q
JOIN sys.query_store_plan p ON p.query_id = q.query_id
JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id
JOIN sys.query_store_runtime_stats_interval i
  ON i.runtime_stats_interval_id = rs.runtime_stats_interval_id
WHERE q.query_hash = 0x1E34C17E155296A7
  AND rs.last_execution_time &gt;= @from
GROUP BY i.start_time, i.end_time;</pre>
<pre>interval_start_utc  interval_end_utc  execs  reads    first_seen_utc       last_seen_utc
2026-09-22 09:00    2026-09-22 10:00  8      334,584  2026-09-22 09:35:00  2026-09-22 09:35:03</pre>
<p style="text-align: justify;">The interval is an hour wide, which is the default, so the row covers 09:00 to 10:00. The execution times inside it are what pin the crime down to three seconds. Filter on those, not on the interval&#8217;s start. Otherwise an interval that began forty-five minutes ago drops out of your window.</p>
<p style="text-align: justify;">Eight runs in three seconds isn&#8217;t somebody typing. It&#8217;s something automated, and Query Store can&#8217;t tell me which job. That&#8217;s the next place to look, in the job history or the application log.</p>
<h2>Why Query Store and not the plan cache</h2>
<p style="text-align: justify;">The plan cache would have found it too, and I checked. But the plan cache forgets. A restart, memory pressure, or a busy afternoon and the evidence is gone. Query Store writes to disk and keeps it for as long as you tell it to. That&#8217;s why it&#8217;s the tool for anything that happened while you were asleep.</p>
<p style="text-align: justify;">It was on by default on this database, capturing everything, with a 1,000 MB budget. Check yours before you need it.</p>
<p><img loading="lazy" decoding="async" class="wp-image-214667" style="max-width: 100%; height: auto;" src="https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-jail.webp" alt="Old west poster illustration of a small jail cell with a printed execution plan behind the bars." width="1672" height="941" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-jail.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-jail-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-jail-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/09/wanted-the-jail-600x338.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h2>Hang this one up</h2>
<p style="text-align: justify;">The four queries above are the whole method. One window, then total reads, then group by hash, then the plan, then the interval. Ten minutes from alert to poster, and the index took another two.</p>
<p style="text-align: justify;">If you&#8217;d like these queries tuned for your instance, with the intervals and retention set right, <a href="https://blog.sqlauthority.com/consulting/">that&#8217;s a morning&#8217;s work</a>.</p>
<p style="text-align: justify;"><strong>A mystery query is not gone, it is in Query Store wearing a different literal.</strong></p>
<p style="text-align: justify;">Published by <strong>Pinal Dave</strong> on <a href="https://blog.sqlauthority.com/">SQLAuthority</a>. More of my work at <a href="https://pinaldave.com/" target="_blank" rel="noopener">pinaldave.com</a>.</p>
</div>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/10/30/wanted-the-3am-query/">Find the Query That Ran at 3 a.m.: A Wanted Poster</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sqlauthority.com/2026/10/30/wanted-the-3am-query/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">214677</post-id>	</item>
		<item>
		<title>Claude on SQL Server: Read, Prove, Then Change</title>
		<link>https://blog.sqlauthority.com/2026/10/29/claude-on-sql-server-read-prove-then-change/</link>
					<comments>https://blog.sqlauthority.com/2026/10/29/claude-on-sql-server-read-prove-then-change/#respond</comments>
		
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Thu, 29 Oct 2026 01:30:00 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Query Store]]></category>
		<category><![CDATA[SQL Performance]]></category>
		<category><![CDATA[SQL Server Security]]></category>
		<category><![CDATA[SQL Wait Stats]]></category>
		<guid isPermaLink="false">https://blog.sqlauthority.com/?p=226214</guid>

					<description><![CDATA[<p>Claude on SQL Server is safe when production gives it eyes and nothing else. This post splits the loop into three stages: start this week with a read-only login, make it a daily habit with a past cases library, then run it on a schedule with a second opinion. I tested the login on SQL Server 2025.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/10/29/claude-on-sql-server-read-prove-then-change/">Claude on SQL Server: Read, Prove, Then Change</a></p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;"><strong>Claude on SQL Server works best when it can read everything about performance and change nothing in production.</strong> A read-only login enforces that rule. A library of past cases then makes each investigation faster than the last.</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Gouache painting of a thick glass observation window in a slate-blue wall, a quiet sage workshop visible inside, a wooden rail in front and one vermilion lantern hanging from the frame" class="wp-image-226206" height="810" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-cover.webp" style="max-width: 100%; height: auto;" width="1440" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-cover.webp 1440w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-cover-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-cover-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-cover-600x338.webp 600w" sizes="auto, (max-width: 1440px) 100vw, 1440px" /></p>
<h2>Where This Comes From</h2>
<p style="text-align: justify;">A few of the teams I work with use the same loop every day. Their DBAs and developers find slow queries, test fixes safely and keep a record of what they learned. I asked one team how they run it. They shared their working document, and I removed everything specific to them.</p>
<p style="text-align: justify;">None of it needs new servers or special tools. With Claude, a production server and a staging copy, you can do it yourself, starting this week. Teams that run this loop get evidence every morning. Other teams keep guessing, and the gap grows each week.</p>
<h2>How the Loop Fits Together</h2>
<p style="text-align: justify;">Production only ever sees Claude&#8217;s reads. Staging sees Claude&#8217;s changes. A person decides what ships. Three stages build on each other: start this week, make it a habit, then automate it.</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Diagram of a six-step loop with a past cases library. Production SQL Server gives Claude a read-only login. Claude reads past cases, then investigates. A staging server proves the change. A replay pack keeps the evidence and is saved into the searchable past cases library. A DBA reviews it, and the change ships and is rechecked. A banner reads: Claude never writes to production." class="wp-image-226217" height="1150" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-diagram-v2.webp" style="max-width: 100%; height: auto;" width="1672" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-diagram-v2.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-diagram-v2-500x344.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-diagram-v2-800x550.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-diagram-v2-600x413.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h2>Stage 1: Start This Week</h2>
<p style="text-align: justify;">Five days, one real finding. Aim for one tested fix by Friday.</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Quick reference card: Start This Week" class="wp-image-226208" height="941" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-1.webp" style="max-width: 100%; height: auto;" width="1672" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-1.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-1-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-1-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-1-600x338.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h3>Day 1: The Read-Only Login and a Staging Copy</h3>
<p style="text-align: justify;">One login on production sees performance data and definitions, never table rows. Restore a fresh copy of production to staging the same day. The login is the guardrail, not the prompt.</p>
<pre class="sqla-plain-code" style="overflow-x:auto;padding:1rem;background:#f4f6f8;border-radius:6px;line-height:1.6;text-align:left;">-- On production: a login that can look, not touch
USE master;
CREATE LOGIN claude_reader WITH PASSWORD = 'Your strong password here';
GRANT VIEW SERVER STATE TO claude_reader;
GRANT VIEW ANY DEFINITION TO claude_reader;
-- Repeat in each database Claude should read
USE YourDatabase;
CREATE USER claude_reader FOR LOGIN claude_reader;
GRANT VIEW DATABASE STATE TO claude_reader;
GRANT SHOWPLAN TO claude_reader;
-- SQL Server 2022 and later: VIEW SERVER PERFORMANCE STATE is narrower</pre>
<p style="text-align: justify;">In my test on SQL Server 2025, the login read waits, plans and Query Store, and every SELECT on a table failed with Msg 229. Test yours with EXECUTE AS LOGIN before you hand it over.</p>
<h3>Day 2: The First Morning Report</h3>
<p style="text-align: justify;">Save this prompt in Claude&#8217;s project instructions, so every run asks the same questions.</p>
<pre class="sqla-plain-code" style="overflow-x:auto;padding:1rem;background:#f4f6f8;border-radius:6px;line-height:1.6;text-align:left;">Using the claude_reader login on PROD, review the last 24 hours: top waits,
top queries by CPU and duration from Query Store, plans that changed or got
slower, and blocking. For each finding, give one hypothesis, its evidence and
the test to run on STAGING. Change nothing on PROD.</pre>
<p style="text-align: justify;">Claude turns the answers into a short list. Each line carries its evidence and a test, so nobody starts the day guessing.</p>
<div style="overflow-x:auto;margin:1.4rem 0;">
<table style="border-collapse:collapse;width:100%;min-width:640px;font:15px/1.5 Arial,sans-serif;">
<thead>
<tr>
<th style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;background:#f4f6f8;">Finding</th>
<th style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;background:#f4f6f8;">Evidence</th>
<th style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;background:#f4f6f8;">Hypothesis and test on staging</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">Order history procedure is 4 times slower since Tuesday</td>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">Query Store shows a new plan. Average time went from 0.5 to 2.1 seconds.</td>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">The plan changed after a statistics update. Test both plans with a small and a large customer.</td>
</tr>
<tr>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">Disk read waits are up since yesterday</td>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">PAGEIOLATCH_SH grew the most since the last report.</td>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">The nightly invoice report scans the whole table. Test an index on the invoice date.</td>
</tr>
<tr>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">40 seconds of blocking at 9:05 AM</td>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">The stock sync job&#8217;s UPDATE led the blocking chain.</td>
<td style="border:1px solid #d0d7de;padding:6px 10px;text-align:left;vertical-align:top;">One long transaction holds the locks. Test the job in smaller batches.</td>
</tr>
</tbody>
</table>
</div>
<p style="text-align: justify;">This is an illustrative example. The object names and numbers are made up.</p>
<h3>Day 3: Prove One Finding on Staging</h3>
<p style="text-align: justify;">Pick one finding and ask Claude for one hypothesis you can test. A good hypothesis names an object and a cause. Claude runs the query on staging, applies the change and runs it again. Then it compares duration, CPU, reads and plan shape.</p>
<h3>Day 4: Save the First Replay Pack</h3>
<p style="text-align: justify;">Save everything from the test in one folder, so anyone can rerun it a month later. A wrong idea gets a pack too. That stops the team testing it twice.</p>
<pre class="sqla-plain-code" style="overflow-x:auto;padding:1rem;background:#f4f6f8;border-radius:6px;line-height:1.6;text-align:left;">order-history-slowdown\
  notes.md       idea, result
  query.sql      text, parameters
  plan-before    actual plan
  plan-after     actual plan
  baseline.csv   time, CPU, reads
  change.sql     the tested fix
  rollback.sql   how to undo it</pre>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Gouache painting of a wooden drawer pulled halfway out of a slate-blue cabinet, glass-sealed sample trays inside and one tray with a vermilion ribbon tab" class="wp-image-226209" height="810" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-evidence.webp" style="max-width: 100%; height: auto;" width="1440" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-evidence.webp 1440w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-evidence-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-evidence-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-evidence-600x338.webp 600w" sizes="auto, (max-width: 1440px) 100vw, 1440px" /></p>
<h3>Day 5: Review, Decide and Ship</h3>
<p style="text-align: justify;">A person reads the evidence, then approves the change, asks for another test or rejects it. The DBA team ships it in a planned window with the rollback ready. Staging can&#8217;t copy live traffic, so a gain there is evidence, not a guarantee. The next morning, Claude confirms the gain held on production.</p>
<p style="text-align: justify;"><strong>You&#8217;re ready for Stage 2 when you have one reviewed fix, one replay pack and a morning report you read every day.</strong></p>
<h2>Stage 2: Make It a Habit</h2>
<p style="text-align: justify;">Stage 1 proves the loop works. Stage 2 makes it run every day, so it no longer depends on one enthusiastic person.</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Quick reference card: Make It a Habit" class="wp-image-226210" height="941" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-2.webp" style="max-width: 100%; height: auto;" width="1672" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-2.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-2-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-2-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-2-600x338.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<h3>The Routine</h3>
<p style="text-align: justify;">Don&#8217;t save this for emergencies. When a crunch comes, the baseline and the replay packs are already there.</p>
<ul>
<li><strong>Daily, about 20 minutes:</strong> Claude writes the morning report. The team picks one or two items, and Claude tests them on staging.</li>
<li><strong>Weekly, about an hour:</strong> replay the week&#8217;s packs, approve what passed and book the window. Note where Claude was wrong and update its instructions.</li>
<li><strong>Monthly, half a day:</strong> refresh staging from a recent backup, review indexes and statistics, and retire packs that no longer matter.</li>
</ul>
<h3>A Pack for Every Case</h3>
<p style="text-align: justify;">Every investigation gets a replay pack, wrong ideas included. Keep the folder layout and the file names identical, so packs are easy to review and easy to search.</p>
<h3>The Past Cases Library</h3>
<p style="text-align: justify;">Every morning report and replay pack goes into a shared folder that Claude can search. This setup is called RAG, short for retrieval augmented generation. Before a new investigation, Claude reads past cases that touched the same query, table or wait type.</p>
<p style="text-align: justify;">Without that memory, each investigation starts from zero, and lessons leave when someone moves on. With it, the hundredth case is faster than the first. The library becomes the team&#8217;s best documentation.</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Gouache painting of an archive alcove in a slate blue wall, shelves of identical cream folders, one with a vermilion ribbon bookmark, and an open folder on a wooden reading table" class="wp-image-226211" height="810" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-library.webp" style="max-width: 100%; height: auto;" width="1440" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-library.webp 1440w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-library-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-library-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-sql-server-tuning-loop-library-600x338.webp 600w" sizes="auto, (max-width: 1440px) 100vw, 1440px" /></p>
<p style="text-align: justify;">Your first replay pack is the library&#8217;s first entry. Then add one sentence to the morning prompt: &#8220;Check the past cases library first.&#8221;</p>
<h3>The Ground Rules</h3>
<ul>
<li>No write access to production, ever.</li>
<li>One change at a time, each with a rollback script.</li>
<li>Staging holds masked data where required.</li>
<li>Reports stay internal. Query text has values: in my test, the Query Store text of one call showed the date I typed.</li>
<li>Nothing ships until a person reads the evidence.</li>
</ul>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Quick reference card: Ground Rules" class="wp-image-226212" height="941" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-6.webp" style="max-width: 100%; height: auto;" width="1672" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-6.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-6-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-6-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-6-600x338.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<p style="text-align: justify;"><strong>You&#8217;re ready for Stage 3 when the routine has run for a few weeks without anyone chasing it, and Claude cites past cases in its findings.</strong></p>
<h2>Stage 3: The Ultimate Setup</h2>
<p style="text-align: justify;">This is where the teams that run the loop every day end up. Each piece builds on what you already have.</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" alt="Quick reference card: The Ultimate Setup" class="wp-image-226213" height="941" src="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-3.webp" style="max-width: 100%; height: auto;" width="1672" srcset="https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-3.webp 1672w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-3-500x281.webp 500w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-3-800x450.webp 800w, https://blog.sqlauthority.com/wp-content/uploads/2026/10/claude-on-sql-server-read-prove-then-change-card-3-600x338.webp 600w" sizes="auto, (max-width: 1672px) 100vw, 1672px" /></p>
<ul>
<li><strong>A schedule:</strong> a scheduler calls Claude through the API with the same morning prompt and the same read-only login. The report is waiting when the team logs in.</li>
<li><strong>A second opinion:</strong> the same evidence goes to Claude and to OpenAI&#8217;s Codex. A fix moves ahead when both agree, and a DBA settles any difference.</li>
<li><strong>One person leads:</strong> a senior member owns the shift. They keep the instructions and the library current, and bring DBAs and developers into the same loop.</li>
<li><strong>The library as memory:</strong> new people read it to learn the system, and the daily work keeps it current.</li>
</ul>
<p style="text-align: justify;">A review step is too slow in a real outage. Your DBA acts first, and the loop pays off on the ordinary days around it.</p>
<p style="text-align: justify;"><strong>You&#8217;ve arrived when the report is waiting every morning, two models have checked each fix and the library is the first place anyone looks.</strong></p>
<h2>Advanced: How the Pieces Connect</h2>
<p style="text-align: justify;">Claude reaches production through Claude Code on a jump box that the DBA team controls. It connects with sqlcmd, or with an MCP server for SQL Server, and only as claude_reader. Staging gets its own login, which can change things there and nowhere else. Keep both passwords in the operating system&#8217;s credential store, never in the prompt.</p>
<p style="text-align: justify;">Start the library as a plain shared folder, one folder per case, with the same file names every time. Claude Code searches it with ordinary text search, and that&#8217;s enough while the library is small. As it grows, add a vector index over the notes and reports. Then Claude finds a case by meaning, such as &#8220;slow after a statistics update&#8221;, not only by exact names. Tag every pack with the query hash, table and wait type, so both kinds of search land on the right case.</p>
<h2>Give This Post to Claude</h2>
<p style="text-align: justify;">You don&#8217;t need to build this by hand. Share this post with Claude and ask:</p>
<pre class="sqla-plain-code" style="overflow-x:auto;padding:1rem;background:#f4f6f8;border-radius:6px;line-height:1.6;text-align:left;">Here is a guide for tuning SQL Server
with Claude:
https://blog.sqlauthority.com/2026/10/29/claude-on-sql-server-read-prove-then-change/
Help us set it up, one step at a time.
Ask before anything touches a server.</pre>
<p style="text-align: justify;">Every stage here is something your team can do on its own. If you&#8217;d rather have it running in weeks than months, I set this up for teams. My <strong><a href="https://blog.sqlauthority.com/consulting/">consulting page</a></strong> has the details.</p>
<p style="text-align: justify;">I wrote about the habit behind the DBA review in <strong><a href="https://pinaldave.com/book/how-to-check-ai-fast.html" rel="noopener" target="_blank">How to Check AI Fast</a></strong>. It&#8217;s an essay about putting your checking effort where a wrong answer costs the most. It&#8217;s one of thirty essays in my book <strong>AI: Nobody&#8217;s in There. But we&#8217;re still in here.</strong> All of them are <strong><a href="https://pinaldave.com/book/" rel="noopener" target="_blank">free to read online</a></strong>, and the paperback is on <strong><a href="https://www.amazon.com/dp/B0H4T6W21S" rel="nofollow noopener" target="_blank">Amazon</a></strong>.</p>
<p style="text-align: justify;"><strong>Claude is not a replacement for your DBAs, it is the investigator that gives them evidence every morning.</strong></p>
<p>Published by <strong>Pinal Dave</strong> on <a href="https://blog.sqlauthority.com/">SQLAuthority</a>. More of my work at <a href="https://pinaldave.com/" rel="noopener" target="_blank">pinaldave.com</a>.</p>
<p>First appeared on <a href="https://blog.sqlauthority.com/2026/10/29/claude-on-sql-server-read-prove-then-change/">Claude on SQL Server: Read, Prove, Then Change</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sqlauthority.com/2026/10/29/claude-on-sql-server-read-prove-then-change/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">226214</post-id>	</item>
	</channel>
</rss>
