<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Databases on Andy M Mallon - AM²</title><link>https://am2.co/category/databases/</link><description>Recent content in Databases on Andy M Mallon - AM²</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 07 Mar 2025 16:17:43 -0500</lastBuildDate><atom:link href="https://am2.co/category/databases/index.xml" rel="self" type="application/rss+xml"/><item><title>Consuming SQL Agent dates &amp; durations</title><link>https://am2.co/2025/03/07/consuming-sql-agent-dates-durations/</link><pubDate>Fri, 07 Mar 2025 16:17:43 -0500</pubDate><guid>https://am2.co/2025/03/07/consuming-sql-agent-dates-durations/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=vBynw9Isr28"&gt;&lt;img src="https://am2.co/wp-content/uploads/StopWatch-300x300.png" alt="" width="300" height="300" class="alignright size-medium wp-image-57887" /&gt;&lt;/a&gt;&#10;SQL Agent&amp;rsquo;s schema is older than me. It handles dates, times, and durations like it&amp;rsquo;s 1980 by using integers instead of date/time data types. My buddy Aaron Bertrand talks more about &lt;a href="https://sqlblog.org/dates" target="_blank"&gt;Dating Responsibly&lt;/a&gt; so that you can have a good datetime with your own database.&lt;/p&gt;</description></item><item><title>Migrating my Stack Overflow answers to blog posts (Sorry for the spam)</title><link>https://am2.co/2024/11/11/migrating-my-stack-overflow-answers-to-blog-posts-sorry-for-the-spam/</link><pubDate>Mon, 11 Nov 2024 17:21:05 -0500</pubDate><guid>https://am2.co/2024/11/11/migrating-my-stack-overflow-answers-to-blog-posts-sorry-for-the-spam/</guid><description>&lt;p&gt;&lt;a href="https://am2.co/wp-content/uploads/stackoverflow-icon.webp"&gt;&lt;img src="https://am2.co/wp-content/uploads/stackoverflow-icon-300x300.webp" alt="" width="300" height="300" class="alignright size-medium wp-image-55224" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;For a while, I have been thinking about using &lt;a href="https://am2.co/category/stack-exchange/" rel="noopener" target="_blank"&gt;my Stack Overflow answers&lt;/a&gt; (and answers on other sites on the Stack Exchange Network), and storing a copy of them here, on my blog as well. All posts on the Stack Exchange network are covered under the &lt;a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en" rel="noopener" target="_blank"&gt;Creative Commons BY-SA license&lt;/a&gt;. When Stack Overflow was created, this license was chosen to ensure that Q&amp;amp;A data remained an open data repository. Posts can be freely reused, re-published, etc, so long as attribution is provided (who is the post &lt;code&gt;BY&lt;/code&gt;, and where it was published), and derivative versions are also shared under the same license (ie, &lt;code&gt;S&lt;/code&gt;hare &lt;code&gt;A&lt;/code&gt;like).&lt;/p&gt;</description></item><item><title>Not all stats should be auto-updated</title><link>https://am2.co/2024/08/29/not-all-stats-should-be-auto-updated/</link><pubDate>Thu, 29 Aug 2024 11:19:07 -0400</pubDate><guid>https://am2.co/2024/08/29/not-all-stats-should-be-auto-updated/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=CO__LF_m_O8"&gt;&lt;img src="https://am2.co/wp-content/uploads/StatsDog-300x300.png" alt="" width="300" height="300" class="alignright size-medium wp-image-53810" /&gt;&lt;/a&gt;Statistics auto-updates are generally a good thing&amp;ndash;auto-update of &lt;a href="https://learn.microsoft.com/en-us/sql/relational-databases/statistics/statistics?view=sql-server-ver16" rel="noopener" target="_blank"&gt;statistics&lt;/a&gt; is the default behavior in SQL Server. Having the freshest information about the data &amp;ldquo;shape&amp;rdquo; helps to inform the best selection of an execution plan for queries.&lt;/p&gt;&#10;&lt;h2 id="except-for-when-it-doesnt"&gt;Except for when it doesn&amp;rsquo;t.&lt;/h2&gt;&#10;&lt;h3 id="because-it-depends"&gt;Because It Depends™️&lt;/h3&gt;&#10;&lt;p&gt;Let&amp;rsquo;s talk about the trade-offs.&lt;/p&gt;</description></item><item><title>T-SQL Tuesday: The last ticket I closed</title><link>https://am2.co/2024/02/13/the-last-ticket-i-closed/</link><pubDate>Tue, 13 Feb 2024 12:41:20 -0500</pubDate><guid>https://am2.co/2024/02/13/the-last-ticket-i-closed/</guid><description>&lt;p&gt;&lt;a href="https://www.brentozar.com/archive/2024/02/tsql2sday-invitation-describe-the-most-recent-issue-you-closed/"&gt;&lt;img src="https://am2.co/wp-content/uploads/TSQLTuesday1.jpg" alt="T-SQL Tuesday logo" width="300" height="300" class="alignright size-full wp-image-395" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;blockquote&gt;For &lt;a href="https://www.brentozar.com/archive/2024/02/tsql2sday-invitation-describe-the-most-recent-issue-you-closed/"&gt;this month's T-SQL Tuesday&lt;/a&gt;, Brent Ozar (&lt;a href="http://www.brentozar.com/archive/author/brento/" rel="noopener" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://instagram.com/BrentO" rel="noopener" target="_blank"&gt;Instagram&lt;/a&gt;) asks us to describe the most recent ticket we closed.&lt;/blockquote&gt;&#10;&lt;h2 id="we-had-a-pretty-significant-wait-spike"&gt;&amp;ldquo;We had a pretty significant wait spike&amp;hellip;&amp;rdquo;&lt;/h2&gt;&#10;&lt;p&gt;The literal last ticket I closed was &amp;ldquo;please run this script in production&amp;hellip;&amp;rdquo;, and I don&amp;rsquo;t think it would be a very interesting blog post to talk about how I copy &amp;amp; pasted a query into SSMS, so let&amp;rsquo;s talk about &lt;em&gt;a recent&lt;/em&gt; ticket instead, from the last couple of weeks.&lt;/p&gt;</description></item><item><title>Enforce a specific constraint to be checked first?</title><link>https://am2.co/2023/10/06/enforce-a-specific-constraint-to-be-checked-first/</link><pubDate>Fri, 06 Oct 2023 21:09:33 -0400</pubDate><guid>https://am2.co/2023/10/06/enforce-a-specific-constraint-to-be-checked-first/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/77247392/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have the following SQL Server table :&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;-- column names with their data types and properties&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;identity&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;primary&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;User&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Job&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;-- table limitations&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;constraint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UniqueUserPerAccount&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;unique&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;User&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;constraint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UniqueJobPerAccount&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;unique&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Job&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the two constraints I listed the more important constraint first hoping that if both constraints are violated, the first one would be triggered and displayed to the user. However, it appears the constraints are declared alphabetically by column name and therefore if both constraints fail, the &lt;code&gt;UniqueJobPerAccount&lt;/code&gt; error, and only this error, is stated to have been violated.&lt;/p&gt;</description></item><item><title>AG secondary is out of sync for hours after index maintenance</title><link>https://am2.co/2023/02/21/ag-secondary-is-out-of-sync-for-hours-after-index-maintenance/</link><pubDate>Tue, 21 Feb 2023 13:17:04 -0500</pubDate><guid>https://am2.co/2023/02/21/ag-secondary-is-out-of-sync-for-hours-after-index-maintenance/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/323858/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have a 3TB OLTP database running Siemens Opcenter MES software at one of our manufacturing plants in China. This is setup in an Always-On Availability group with one secondary node. As this is a manufacturing plant, we are only provided 11 1/2 hours every two weeks to run index maintenance when the plant is not running production. We use Hallengren scripts to run this index maintenance.&lt;/p&gt;</description></item><item><title>Using OPENJSON, can't get results to GROUP BY</title><link>https://am2.co/2022/12/24/using-openjson-cant-get-results-to-group-by/</link><pubDate>Sat, 24 Dec 2022 18:35:57 -0500</pubDate><guid>https://am2.co/2022/12/24/using-openjson-cant-get-results-to-group-by/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/306522/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm passing a JSON string to a stored procedure in order to insert warehouse inventory.&lt;/p&gt;&#10;&lt;p&gt;Sometimes, there will be multiple line items with the same product, going to the same shelf, on the same pallet (LPN), with the same date. I would like to aggregate those into one line in the table.&lt;/p&gt;</description></item><item><title>SQL Modulo Function gives the wrong value?</title><link>https://am2.co/2022/11/18/sql-modulo-function-gives-the-wrong-value/</link><pubDate>Fri, 18 Nov 2022 15:04:29 -0500</pubDate><guid>https://am2.co/2022/11/18/sql-modulo-function-gives-the-wrong-value/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/319890/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In Javascript, Excel, Python, and a scientific calculator, the modulo operation&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;34086&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1576962834&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="c1"&gt;-- python&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;MOD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;34086&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1576962834&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="c1"&gt;-- Excel function&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;gives a value of &lt;code&gt;113.84230371659942&lt;/code&gt;. (Or something very close to that, depending on number of decimal places and rounding.)&lt;/p&gt;</description></item><item><title>Is SQL Server affected by OpenSSL 3.0 Vulnerabilities: CVE 2022-3786 and CVE 2022-3602</title><link>https://am2.co/2022/11/08/is-sql-server-affected-by-openssl-3-0-vulnerabilities-cve-2022-3786-and-cve-2022-3602/</link><pubDate>Tue, 08 Nov 2022 03:30:24 -0500</pubDate><guid>https://am2.co/2022/11/08/is-sql-server-affected-by-openssl-3-0-vulnerabilities-cve-2022-3786-and-cve-2022-3602/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/319330/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to establish whether SQL Server is affected by the recently discovered OpenSSL vulnerabilities. For example, are SQL Servers that are using TLS/Certificates to encrypt connections between client and server affected to? I believe SQL Server uses Open SSL libraries for encryption purposes. Can someone please shed light on this?&lt;/p&gt;</description></item><item><title>What's the use case of disabling an index?</title><link>https://am2.co/2022/09/25/whats-the-use-case-of-disabling-an-index/</link><pubDate>Sun, 25 Sep 2022 17:10:28 -0400</pubDate><guid>https://am2.co/2022/09/25/whats-the-use-case-of-disabling-an-index/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/317371/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I just learned that indexes can be disabled on a table. Even the clustered index can be disabled. After that, users can&amp;rsquo;t access the index or the data if clustered index. When will we disable an index? I just don&amp;rsquo;t understand the use case.&lt;/p&gt;</description></item><item><title>What ports to open for sql server behind secure domain firewall</title><link>https://am2.co/2022/08/25/what-ports-to-open-for-sql-server-behind-secure-domain-firewall/</link><pubDate>Thu, 25 Aug 2022 21:34:17 -0400</pubDate><guid>https://am2.co/2022/08/25/what-ports-to-open-for-sql-server-behind-secure-domain-firewall/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/316082/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We are trying to solve connectivity issues for one of the app trying to pull data from very secured sql server behind firewall. I am not that expertise in security but need help on how to proceed in opening ports for that app to pull data from sql server behind secure domain.&lt;/p&gt;</description></item><item><title>snapshot replication - corrupted BCP files</title><link>https://am2.co/2022/08/18/snapshot-replication-corrupted-bcp-files/</link><pubDate>Thu, 18 Aug 2022 22:56:09 -0400</pubDate><guid>https://am2.co/2022/08/18/snapshot-replication-corrupted-bcp-files/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/315798/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Each night my SQLServer replication failed on a big table with the following error. It is failing on a different table each night but always on a relatively big table ( &amp;gt; 200,000 rows)&lt;/p&gt;&#10;&lt;p&gt;The process could not bulk copy into table '&amp;quot;dbo&amp;quot;.&amp;quot;Table01&amp;quot;'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20037)&lt;br /&gt;&#10;Get help: http://help/MSSQL_REPL20037&lt;br /&gt;&#10;&lt;strong&gt;Field size too large&lt;br /&gt;&#10;Batch send failed&lt;/strong&gt;&lt;br /&gt;&#10;Violation of PRIMARY KEY constraint 'PK_Table01'. Cannot insert duplicate key in object 'dbo.Table01'. The duplicate key value is (0). (Source: MSSQLServer, Error number: 2627)&lt;br /&gt;&#10;Get help: http://help/2627&lt;br /&gt;&#10;Failed to send batch after max errors (Source: MSSQLServer, Error number: 3621)&lt;br /&gt;&#10;Get help: http://help/3621&lt;/p&gt;</description></item><item><title>GRANT ADMINISTER Database Bulk Operations - Incorrect syntax near ADMINISTER</title><link>https://am2.co/2022/05/23/grant-administer-database-bulk-operations-incorrect-syntax-near-administer/</link><pubDate>Mon, 23 May 2022 01:51:34 -0400</pubDate><guid>https://am2.co/2022/05/23/grant-administer-database-bulk-operations-incorrect-syntax-near-administer/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/312469/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to import a bacpac file to my SQL Server Express 2016.&#10;An exception is thrown during the import with&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;GRANT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ADMINISTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Database&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Bulk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Operations&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;MyUser&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Returns:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;Incorrect syntax near 'ADMINISTER'.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;I am running the import as the &lt;code&gt;sa&lt;/code&gt; user. Later when I try to run the SQL line directly, the same error is thrown. What can I do to resolve this?&lt;/p&gt;</description></item><item><title>How do I generate the private key needed to restore the encrypted backup?</title><link>https://am2.co/2022/04/22/how-do-i-generate-the-private-key-needed-to-restore-the-encrypted-backup/</link><pubDate>Fri, 22 Apr 2022 01:10:13 -0400</pubDate><guid>https://am2.co/2022/04/22/how-do-i-generate-the-private-key-needed-to-restore-the-encrypted-backup/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/311218/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm simulating the situation where I take a backup from instance &lt;strong&gt;A&lt;/strong&gt; and restore it on instance &lt;strong&gt;B&lt;/strong&gt;. I followed the doc to &lt;a href="https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/create-an-encrypted-backup?view=sql-server-ver15#backup-to-disk-with-encryption" rel="nofollow noreferrer"&gt;Backup to Disk with Encryption&lt;/a&gt;. Since I'm using only my desktop to simulate the whole process, after taking the backup of the database I took a backup of the certificate that was used as follows:&lt;/p&gt;</description></item><item><title>Temporarily turn on Cascade Delete</title><link>https://am2.co/2022/04/20/temporarily-turn-on-cascade-delete/</link><pubDate>Wed, 20 Apr 2022 10:02:25 -0400</pubDate><guid>https://am2.co/2022/04/20/temporarily-turn-on-cascade-delete/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/312379/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This has probably been asked before, but I couldn't find the answer.&lt;/p&gt;&#10;&lt;p&gt;I have a complex datamodel in sql-server-20XX (more likely to be something old) in which cascade delete has been turned off (by design).&lt;/p&gt;&#10;&lt;p&gt;A large chunk of our database has been sold (I can make the distinction on the top-level) and there are reasons why we want to delete that data. I want to do that in a single script, in which I first turn on cascade delete, than delete all the data, than turn off cascade delete again, but I can't find the correct syntax.&lt;/p&gt;</description></item><item><title>SQL Main query value used in the WHERE in the subquery</title><link>https://am2.co/2022/03/09/sql-main-query-value-used-in-the-where-in-the-subquery/</link><pubDate>Wed, 09 Mar 2022 16:02:11 -0500</pubDate><guid>https://am2.co/2022/03/09/sql-main-query-value-used-in-the-where-in-the-subquery/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/308497/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm really confused by this SQL here, I have this sample where I am using the value from the main query in the subquery and then using XML PATH to add a comma between the dates. The setup is 2 tables one with the dates I want to string together. I am not sure why the subquery where statement is not retuning the correct results.&lt;/p&gt;</description></item><item><title>How do I prevent a trigger from firing for one process?</title><link>https://am2.co/2022/03/08/how-do-i-prevent-a-trigger-from-firing-for-one-process/</link><pubDate>Tue, 08 Mar 2022 09:00:16 -0500</pubDate><guid>https://am2.co/2022/03/08/how-do-i-prevent-a-trigger-from-firing-for-one-process/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=RLG-jkwuwh8" rel="noopener" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/julius-drost-C8wlYF8ubBo-unsplash-769x1024.jpg" alt="playing cards on fire" width="384" height="512" class="alignright size-large wp-image-11594" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I recently saw a question on DBA Stack Exchange (it has since been deleted by the author), who had a &amp;ldquo;special process&amp;rdquo; that ran regularly, and as part of that process, they disabled the trigger, did some stuff, and re-enabled it. During that process, the step that disables the trigger would deadlock, and cause problems. So the asker was wondering how to catch &amp;amp; handle the deadlock during the &lt;code&gt;DISABLE TRIGGER&lt;/code&gt; step.&lt;/p&gt;</description></item><item><title>How to await the execution of the rds_backup_database stored procedure?</title><link>https://am2.co/2022/03/03/how-to-await-the-execution-of-the-rds_backup_database-stored-procedure/</link><pubDate>Thu, 03 Mar 2022 13:40:49 -0500</pubDate><guid>https://am2.co/2022/03/03/how-to-await-the-execution-of-the-rds_backup_database-stored-procedure/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/308227/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Our team is migrating one of our databases to Amazon RDS MS SQL Server. As part of that, we have to rewrite some of our stored procedures.&lt;/p&gt;&#10;&lt;p&gt;We have a stored procedure that performs a database backup to a network storage.&lt;/p&gt;</description></item><item><title>How to change the web browser used by SSMS when you hit Ctrl+Alt+R</title><link>https://am2.co/2022/02/15/how-to-change-the-web-browser-used-by-ssms-when-you-hit-ctrlaltr/</link><pubDate>Tue, 15 Feb 2022 01:32:52 -0500</pubDate><guid>https://am2.co/2022/02/15/how-to-change-the-web-browser-used-by-ssms-when-you-hit-ctrlaltr/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/307496/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;When I am running:&lt;/p&gt;&#10;&lt;a href="https://am2.co/wp-content/uploads/dba-se-307496-1.png"&gt;&lt;img src="https://am2.co/wp-content/uploads/dba-se-307496-1-298x300.png" alt="" width="298" height="300" class="aligncenter size-medium wp-image-55798" /&gt;&lt;/a&gt;&#10;&lt;p&gt;Ctrl+Alt+R will run the web browser in an SSMS tab. However, this now produces the message:&lt;/p&gt;&#10;&lt;a href="https://am2.co/wp-content/uploads/dba-se-307496-2.png"&gt;&lt;img src="https://am2.co/wp-content/uploads/dba-se-307496-2-300x58.png" alt="" width="300" height="58" class="aligncenter size-medium wp-image-55799" /&gt;&lt;/a&gt;&#10;&lt;p&gt;I do have MS Edge installed but SSMS is not finding it. What should I do to help SSMS find MS Edge and use it?&lt;/p&gt;</description></item><item><title>Allow create table (dynamic name) and insert but nothing else</title><link>https://am2.co/2022/02/14/allow-create-table-dynamic-name-and-insert-but-nothing-else/</link><pubDate>Mon, 14 Feb 2022 13:43:43 -0500</pubDate><guid>https://am2.co/2022/02/14/allow-create-table-dynamic-name-and-insert-but-nothing-else/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/307467/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm trying to find a way to allow an application to create tables and insert data into them on a SQL Server 2019 while protecting from injection attacks in case the app credentials would leak. My experience is limited when it comes to writing code that can run in parallel and writing dynamic sql that is protected from sql injection attacks.&lt;br /&gt;&#10;The table name is based on input from the application, i.e. if the input is 'nds' the table name should be lake.nds_raw_log.&lt;br /&gt;&#10;It is my understanding that there is no way to do this via directly granting permissions to the role for this application since creating tables is not separated from deleting or altering them.&lt;/p&gt;</description></item><item><title>Add default rows to the query result if restrictions are not met</title><link>https://am2.co/2022/02/10/add-default-rows-to-the-query-result-if-restrictions-are-not-met/</link><pubDate>Thu, 10 Feb 2022 13:12:49 -0500</pubDate><guid>https://am2.co/2022/02/10/add-default-rows-to-the-query-result-if-restrictions-are-not-met/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/307298/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a SQL query that looks for values in a table on a range of dates.&lt;/p&gt;&#10;&lt;p&gt;If no record is found, I would like to generate rows with default values.&lt;/p&gt;&#10;&lt;p&gt;Example of one of the table existing records:&lt;/p&gt;</description></item><item><title>How to revoke SA permissions that seem to be "stuck" to a login?</title><link>https://am2.co/2022/02/02/how-to-revoke-sa-permissions-that-seem-to-be-stuck-to-a-login/</link><pubDate>Wed, 02 Feb 2022 13:29:23 -0500</pubDate><guid>https://am2.co/2022/02/02/how-to-revoke-sa-permissions-that-seem-to-be-stuck-to-a-login/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/307824/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Apologies in advance if I don't use some terminology correctly here. I'm not a DBA but I've been temporarily forced into the role.&lt;/p&gt;&#10;&lt;p&gt;I've inherited an application that runs on SQL Server 2016 Enterprise - one instance for PROD and another for TEST. These instances are set up in an &amp;quot;always on&amp;quot; configuration, so I have one Availability Group for PROD and one for TEST. Each Availability Group has two servers in it. Each instance has multiple databases in it, but only one DB in each instance is actually used by the application - the others look to have been created for testing purposes. I'm only mentioning that there are other DBs just in case it might be relevant in some way that I'm not aware of.&lt;/p&gt;</description></item><item><title>CASE statement issue</title><link>https://am2.co/2022/01/13/case-statement-issue/</link><pubDate>Thu, 13 Jan 2022 19:52:17 -0500</pubDate><guid>https://am2.co/2022/01/13/case-statement-issue/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/306069/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Can anyone help with this error?&lt;/p&gt;&#10;&lt;p&gt;SQL:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;InvoiceDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BillingAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BillingCity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;CASE&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;THEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Baseline Purchase&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BETWEEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;THEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Low Purchase&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BETWEEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;THEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Target Purchase&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ELSE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Top Performer&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PurchaseType&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PurchaseType&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Top Performer&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BY&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BillingCity&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="errorMsg"&gt;Error:&#10;Msg 207, Level 16, State 1, Line 13&#10;Invalid column name 'PurchaseType'.&lt;/div&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/306069/52344" rel="noopener" target="_blank"&gt;2022-01-13&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/246235" rel="noopener" target="_blank"&gt;Mark_72&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Querying SERVERPROPERTY() and DATABASEPROPERTYEX() from a view (without knowing magic)</title><link>https://am2.co/2021/12/17/querying-serverproperty-and-databasepropertyex-from-a-view/</link><pubDate>Fri, 17 Dec 2021 11:11:50 -0500</pubDate><guid>https://am2.co/2021/12/17/querying-serverproperty-and-databasepropertyex-from-a-view/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:378px"&gt;&lt;a href="https://www.youtube.com/watch?v=nF4-OOlbvl8" rel="noopener" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/ElphieWitch_Tall-504x1024.jpg" alt="Puppy in a witch costume" width="378" height="768" class="size-large wp-image-10541" /&gt;&lt;/a&gt; Elphaba the pup is growing up!&lt;/figure&gt;&#10;I'm not going to beat around the bush. I hate the `SERVERPROPERTY()` and `DATABASEPROPERTYEX()` system functions. &#10;&lt;h2 id="loathing"&gt;Loathing&lt;/h2&gt;&#10;&lt;p&gt;The thing I hate the most about these two functions is that you need to know the right magic spells to make them work. Let&amp;rsquo;s look at &lt;code&gt;SERVERPROPERTY()&lt;/code&gt; first. The syntax for the function is &lt;code&gt;SERVERPROPERTY( &amp;lsquo;propertyname&amp;rsquo; )&lt;/code&gt;, which is easy enough syntax, but the list of values for &lt;code&gt;propertyname&lt;/code&gt; isn&amp;rsquo;t discoverable from SQL Server metadata, DMVs, or even IntelliSense. Instead, I need to check &lt;a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver15" rel="noopener" target="_blank"&gt;the docs&lt;/a&gt; for the list of allowable values. These property names are essentially magic words, and I need to check my &lt;a href="https://amzn.to/3H6p0Ph" rel="noopener" target="_blank"&gt;spell book&lt;/a&gt; to make sure I get it right.&lt;/p&gt;</description></item><item><title>Which install kit installs sqlcmd.exe?</title><link>https://am2.co/2021/12/12/which-install-kit-installs-sqlcmd-exe/</link><pubDate>Sun, 12 Dec 2021 19:58:18 -0500</pubDate><guid>https://am2.co/2021/12/12/which-install-kit-installs-sqlcmd-exe/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/303854/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I recently had to uninstall Visual Studio 2012 and DTS, then install VS 2017 and DTS again. Afterwards, The directory containing &lt;code&gt;sqlcmd.exe&lt;/code&gt; was not in my &lt;code&gt;PATH&lt;/code&gt; variable. I installed the following.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;vs_Professional&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;vs2017&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;SSDT&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Setup&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ENU&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;vs2017&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Should either of these kits install &lt;code&gt;sqlcmd.exe&lt;/code&gt;? If not, which tool will install it? I need one that will work with SQL Server 2012+.&lt;/p&gt;</description></item><item><title>log_reuse_wait_desc = AVAILABILITY_REPLICA, log is 100% full but AG is all fine</title><link>https://am2.co/2021/11/28/log_reuse_wait_desc-availability_replica-log-is-100-full-but-ag-is-all-fine/</link><pubDate>Sun, 28 Nov 2021 18:58:02 -0500</pubDate><guid>https://am2.co/2021/11/28/log_reuse_wait_desc-availability_replica-log-is-100-full-but-ag-is-all-fine/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/302301/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;That's a weird scenario. The transaction log is full. It waits on AG. AG is all good. No latency, last commit/hardened time is almost real-time on all the nodes. The Estimated Recovery Time is zero. I checked this from the primary node and secondaries as well (in case if Dashboard is not updating).&#10;This &lt;a href="https://learn.microsoft.com/en-us/troubleshoot/sql/availability-groups/error-9002-transaction-log-large" rel="nofollow noreferrer"&gt;page&lt;/a&gt; lists only two reasons for this error, a delivery latency and redo latency. Nothing applies to my system. How to troubleshoot this further?&lt;/p&gt;</description></item><item><title>Order by one column if not null, otherwise by another column, columns are of not matching types</title><link>https://am2.co/2021/11/28/order-by-one-column-if-not-null-otherwise-by-another-column-columns-are-of-not-matching-types/</link><pubDate>Sun, 28 Nov 2021 18:14:16 -0500</pubDate><guid>https://am2.co/2021/11/28/order-by-one-column-if-not-null-otherwise-by-another-column-columns-are-of-not-matching-types/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/303220/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have an application that uses PostgreSQL as RDBMS. There is a table containing orders placed by customers. The table has an &lt;code&gt;id&lt;/code&gt; as primary key, an &lt;code&gt;order_number&lt;/code&gt; (integer) and a &lt;code&gt;created_at&lt;/code&gt; field (timestamp). &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;created_at&lt;/code&gt; are assigned automatically when the row is created, the &lt;code&gt;order_number&lt;/code&gt; is assigned &amp;quot;manually&amp;quot; (when the person performing the order entry process receives the order confirmation, he presses a button and the order_number is assigned as &lt;code&gt;MAX(order_number) + 1&lt;/code&gt;, this can happen almost immediately or after a few days, or the order can be cancelled so it never receives a number). In the table there are quite a lot of rows with &lt;code&gt;NULL&lt;/code&gt; in the &lt;code&gt;order_number&lt;/code&gt; column: the cancelled and pending confirmation orders. This is an excerpt from the table:&lt;/p&gt;</description></item><item><title>Database context for sys.databases and sys.master_files</title><link>https://am2.co/2021/11/15/database-context-for-sys-databases-and-sys-master_files/</link><pubDate>Mon, 15 Nov 2021 11:45:13 -0500</pubDate><guid>https://am2.co/2021/11/15/database-context-for-sys-databases-and-sys-master_files/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/302628/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a query that pulls information for a database from the following tables&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;sys.master_files&lt;/li&gt;&#10;&lt;li&gt;sys.databases&lt;/li&gt;&#10;&lt;li&gt;sys.filegroups&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Currently, the context set is the specific database which I want to query about.&#10;But if the database is in a mode such that &lt;code&gt;USE DB_NAME&lt;/code&gt; doesn't work,&#10;is it okay to use &lt;code&gt;USE master&lt;/code&gt;?&#10;Since I am adding a &lt;strong&gt;where clause on the basis of &lt;code&gt;DB_NAME&lt;/code&gt;&lt;/strong&gt; will &lt;code&gt;USE DB_NAME&lt;/code&gt; versus &lt;code&gt;USE master&lt;/code&gt; make any difference?&lt;/p&gt;</description></item><item><title>decoding instance_name in sys.dm_os_performance_counters on Azure SQL Database</title><link>https://am2.co/2021/11/09/decoding-instance_name-in-sys-dm_os_performance_counters-on-azure-sql-database/</link><pubDate>Tue, 09 Nov 2021 19:25:23 -0500</pubDate><guid>https://am2.co/2021/11/09/decoding-instance_name-in-sys-dm_os_performance_counters-on-azure-sql-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/302375/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;doing some work with the SQL Perfmon counters and banging my head against the wall trying to work out how to translate the instance_name column to a database name.&#10;So if I run a query like the following&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;left&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;left&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instance_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;cntr_value&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dm_os_performance_counters&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;counter_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Log Bytes Received/sec&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I get a resultset like&lt;/p&gt;</description></item><item><title>SQL Server service - Not Starting With Automatic Startup, "The system cannot find the file specified", but starts fine manually</title><link>https://am2.co/2021/10/29/sql-server-service-not-starting-with-automatic-startup-the-system-cannot-find-the-file-specified-but-starts-fine-manually/</link><pubDate>Fri, 29 Oct 2021 18:56:27 -0400</pubDate><guid>https://am2.co/2021/10/29/sql-server-service-not-starting-with-automatic-startup-the-system-cannot-find-the-file-specified-but-starts-fine-manually/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/301898/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This is a weird one, and I've run out of ideas for how to go about troubleshooting this. Here's the issue, best as I can sum it up.&lt;/p&gt;&#10;&lt;p&gt;The SQL Server engine and Agent services are not started when the server first boots when they're set to Automatic. Looked through the Event Viewer, and found these errors:&lt;/p&gt;</description></item><item><title>Are Basic Availability Groups a reliable HA solution without integrity checks on the secondary replica?</title><link>https://am2.co/2021/10/26/are-basic-availability-groups-a-reliable-ha-solution-without-integrity-checks-on-the-secondary-replica/</link><pubDate>Tue, 26 Oct 2021 16:21:08 -0400</pubDate><guid>https://am2.co/2021/10/26/are-basic-availability-groups-a-reliable-ha-solution-without-integrity-checks-on-the-secondary-replica/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/301705/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have a few Basic Availability groups in production and I've been reading about the &lt;a href="https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/basic-availability-groups-always-on-availability-groups?view=sql-server-ver15#limitations" rel="nofollow noreferrer"&gt;limitations&lt;/a&gt; of them. I'm concerned about the following limitations:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;No backups on secondary replica.&lt;/p&gt;&#10;&lt;p&gt;No integrity checks on secondary replicas.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;Suppose that we haven't failed over in months. In our case, that seems to imply that we haven't run &lt;code&gt;DBCC CHECKDB&lt;/code&gt; for a long time on any of the databases on the secondary. There could have been a storage corruption issue that occurred months ago that we still don't know about. If a disaster occurs on the primary replica and we fail over to the secondary, we might end up with the production application pointing at corrupt data.&lt;/p&gt;</description></item><item><title>Why are there no "Daylight Time" time zones in SQL Server?</title><link>https://am2.co/2021/10/21/why-are-there-no-daylight-time-time-zones-in-sql-server/</link><pubDate>Thu, 21 Oct 2021 23:11:06 -0400</pubDate><guid>https://am2.co/2021/10/21/why-are-there-no-daylight-time-time-zones-in-sql-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/301484/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am converting the times of some datetimeoffset columns from UTC to Eastern. I am doing this via the command&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MyTable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MyColumn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MyColumn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TIME&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ZONE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Eastern Standard Time&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This seemed to be working correctly (times were shifted 4 hours earlier and now have a -04:00 offset, exactly what I wanted), but then I realized that it's not EST, it's EDT right now.&lt;/p&gt;</description></item><item><title>What the heck is the SSISDB? Where does it come from?</title><link>https://am2.co/2021/10/18/what-the-heck-is-the-ssisdb-where-does-it-come-from/</link><pubDate>Mon, 18 Oct 2021 09:00:15 -0400</pubDate><guid>https://am2.co/2021/10/18/what-the-heck-is-the-ssisdb-where-does-it-come-from/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=r3AP26ywQsQ" rel="noopener" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/photo-1619793644997-6f55d1c3cb5c-1024x683.jpg" alt="Two ducks ducking" width="400" height="267" class="alignright size-large wp-image-9636" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Back in my day, we stored SQL Server Integration Services (SSIS) packages in msdb, or the file system. Well, I&amp;rsquo;m neither dead nor retired, so that&amp;rsquo;s not an accurate statement&amp;ndash;today is still &amp;ldquo;my time.&amp;rdquo; But when I was learning about SQL Server, those were the only two options. If you or your environment predate SQL Server 2012, then you might only be familiar with those two options.&lt;/p&gt;</description></item><item><title>How do I put the result of stored procedure in a new column in a view?</title><link>https://am2.co/2021/10/17/how-do-i-put-the-result-of-stored-procedure-in-a-new-column-in-a-view/</link><pubDate>Sun, 17 Oct 2021 06:10:18 -0400</pubDate><guid>https://am2.co/2021/10/17/how-do-i-put-the-result-of-stored-procedure-in-a-new-column-in-a-view/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/69601763/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have created a stored procedure which takes as inputs a schema name and a table name and outputs an INT containing the largest value in the &lt;code&gt;id&lt;/code&gt; column of the table. I have also created a view containing all the schema names, table names, and primary key column names in my database. I would like to add a column to this view containing the result of my stored procedure, using the schema name and table name values as inputs to the row&amp;rsquo;s stored procedure. I have tried a few different things, but I can&amp;rsquo;t find a way to do it.&lt;/p&gt;</description></item><item><title>Is it possible to do a partial transaction log backup with SQL Server 2017? I don't have enough disk space to do a full backup</title><link>https://am2.co/2021/10/15/is-it-possible-to-do-a-partial-transaction-log-backup-with-sql-server-2017-i-dont-have-enough-disk-space-to-do-a-full-backup/</link><pubDate>Fri, 15 Oct 2021 18:12:37 -0400</pubDate><guid>https://am2.co/2021/10/15/is-it-possible-to-do-a-partial-transaction-log-backup-with-sql-server-2017-i-dont-have-enough-disk-space-to-do-a-full-backup/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/301199/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Inherited a database server to maintain and found that the transaction log is 92 GB. My plan is to do the backup of that and get it brought back down to a regular size, then fix it. The problem is I don't have enough disk space on the machine to do the backup locally, then offload. Is there a way I can run the backup for a specified size or time period so I can do it in stages?&lt;/p&gt;</description></item><item><title>Can I use both Log Shipping and Transaction Replication at the same time?</title><link>https://am2.co/2021/10/15/can-i-use-both-log-shipping-and-transaction-replication-at-the-same-time/</link><pubDate>Fri, 15 Oct 2021 11:36:11 -0400</pubDate><guid>https://am2.co/2021/10/15/can-i-use-both-log-shipping-and-transaction-replication-at-the-same-time/</guid><description>&lt;p&gt;&lt;a href="https://serverfault.com/q/1080640/299354"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Good Morning, I have a SQL Server 2016 that is doing Log Shipping to a DR Site. I currently want to also to Replicate (Transactional) specific Tables to another Server for Reporting Purposes.&lt;/p&gt;&#10;&lt;p&gt;Will there be any issues or snafu&amp;rsquo;s I should be aware of? Can I have Log Shipping and Transactional Replication configured on the same Publishing Database?&lt;/p&gt;</description></item><item><title>T-SQL Tuesday #143: My favorite short scripts</title><link>https://am2.co/2021/10/12/t-sql-tuesday-143-my-favorite-short-scripts/</link><pubDate>Tue, 12 Oct 2021 10:00:22 -0400</pubDate><guid>https://am2.co/2021/10/12/t-sql-tuesday-143-my-favorite-short-scripts/</guid><description>&lt;p&gt;&lt;a href="https://johnmccormack.it/2021/10/t-sql-tuesday-143-short-code-examples/"&gt;&lt;img src="https://am2.co/wp-content/uploads/TSQLTuesday1.jpg" alt="T-SQL Tuesday logo" width="300" height="300" class="alignright size-full wp-image-395" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;blockquote&gt;For &lt;a href="https://johnmccormack.it/2021/10/t-sql-tuesday-143-short-code-examples/"&gt;this month's T-SQL Tuesday&lt;/a&gt;, John McCormack (&lt;a href="https://johnmccormack.it/" rel="noopener" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/actualjohn" rel="noopener" target="_blank"&gt;twitter&lt;/a&gt;) asks us: “What are your go-to short, handy scripts”? I've got so many handy dandy scripts, it was hard to choose.&lt;/blockquote&gt;&#10;&lt;h2 id="where-to-start"&gt;Where to start?&lt;/h2&gt;&#10;&lt;p&gt;I have so many go-to scripts that are short, amazing, and I use all the time. I&amp;rsquo;ve been using SQL Server since the turn of the century, and over the last two decades, I&amp;rsquo;ve found and written a lot of helpful things. And I have a terrible memory, so even if it&amp;rsquo;s just a few lines, I often keep it bookmarked or saved for when I need it. As an aside&amp;ndash;remember that having a folder of utility scripts isn&amp;rsquo;t a sign of weakness or incompetence. If anything, it&amp;rsquo;s the opposite&amp;ndash;those utility scripts are basically all battle scars for the database battles you&amp;rsquo;ve fought over your career. As we become senior, we just fine-tune our collection. With seniority, you don&amp;rsquo;t stop having that collection of scripts&amp;ndash;you just get better at curating them, at making them generic &amp;amp; reusable.&lt;/p&gt;</description></item><item><title>What time is it in Oz?</title><link>https://am2.co/2021/10/05/what-time-is-it-in-oz/</link><pubDate>Tue, 05 Oct 2021 15:54:03 -0400</pubDate><guid>https://am2.co/2021/10/05/what-time-is-it-in-oz/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:300px"&gt;&lt;a href="https://www.youtube.com/watch?v=R4rpG-dipYA"&gt;&lt;img src="https://am2.co/wp-content/uploads/ElphiePup2-300x300.jpg" alt="Black dog wearing bandana standing on grass" width="300" height="300" class="size-medium wp-image-9493" /&gt;&lt;/a&gt; This is our puppy &lt;a href="https://en.wikipedia.org/wiki/Elphaba" rel="noopener" target="_blank"&gt;Elphaba&lt;/a&gt;. She's from &lt;a href="https://en.wikipedia.org/wiki/Name_of_Australia#Oz" rel="noopener" target="_blank"&gt;Oz&lt;/a&gt;...No, the &lt;a href="https://en.wikipedia.org/wiki/Land_of_Oz" rel="noopener" target="_blank"&gt;other Oz&lt;/a&gt;. She's &lt;a href="https://www.youtube.com/watch?v=R4rpG-dipYA" rel="noopener" target="_blank"&gt;popular&lt;/a&gt;.&lt;/figure&gt;&#10;&lt;p&gt;There was a &lt;a href="https://dba.stackexchange.com/q/300618/52344" rel="noopener" target="_blank"&gt;recent post on Database Administrators&lt;/a&gt;, where there was some confusion over Daylight Saving Time(DST) in Australian timezones. Let&amp;rsquo;s be honest though&amp;ndash;timezones are confusing, especially when DST comes into play. Arizona Time doesn&amp;rsquo;t observe Daylight Saving Time, so sometimes it&amp;rsquo;s the same as Mountain Time, and sometimes it&amp;rsquo;s Pacific Time.&lt;/p&gt;</description></item><item><title>Database Sizes error; Arithmetic overflow error converting expression to data type int</title><link>https://am2.co/2021/10/01/database-sizes-error-arithmetic-overflow-error-converting-expression-to-data-type-int/</link><pubDate>Fri, 01 Oct 2021 12:53:23 -0400</pubDate><guid>https://am2.co/2021/10/01/database-sizes-error-arithmetic-overflow-error-converting-expression-to-data-type-int/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/300451/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am using the below query to pull back database sizes for our SQL instances.&lt;/p&gt;&#10;&lt;p&gt;This cannot pull data larger than 2TB back because of the maximum number the int data type can pull back. How do I go about altering the query to return the database size, no matter how large the dbs?&lt;/p&gt;</description></item><item><title>SQL Server replication additional subscriber</title><link>https://am2.co/2021/09/15/sql-server-replication-additional-subscriber/</link><pubDate>Wed, 15 Sep 2021 08:48:16 -0400</pubDate><guid>https://am2.co/2021/09/15/sql-server-replication-additional-subscriber/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/299611/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a publisher with the distributor on the same server which is transactional replication.&#10;There is also an active subscriber using push method.&lt;/p&gt;&#10;&lt;p&gt;I need to set a new subscriber up going to a different server using the same articles as the current subscriber I have. The database is huge and cannot be taken offline so I was going to do an initialize from backup instead of a new snapshot.&lt;/p&gt;</description></item><item><title>Always backup database with encryption</title><link>https://am2.co/2021/09/12/always-backup-database-with-encryption/</link><pubDate>Sun, 12 Sep 2021 12:36:06 -0400</pubDate><guid>https://am2.co/2021/09/12/always-backup-database-with-encryption/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/299456/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Is there a way to force all database and log backups run on the server to be encrypted?&lt;/p&gt;&#10;&lt;p&gt;If encryption is not specified, the query will be terminated.&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/299456/52344" rel="noopener" target="_blank"&gt;2021-09-12&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/176952" rel="noopener" target="_blank"&gt;Avi&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;h2 id="not-in-sql-server"&gt;Not in SQL Server&lt;/h2&gt;&#10;&lt;p&gt;There is no option to force &lt;code&gt;BACKUP DATABASE&lt;/code&gt; &amp;amp; &lt;code&gt;BACKUP LOG&lt;/code&gt; to specify &lt;code&gt;WITH ENCRYPTION...&lt;/code&gt; as part of backup commands in SQL Server.&lt;/p&gt;</description></item><item><title>Partitioning and existing Indexes</title><link>https://am2.co/2021/09/12/partitioning-and-existing-indexes/</link><pubDate>Sun, 12 Sep 2021 11:11:25 -0400</pubDate><guid>https://am2.co/2021/09/12/partitioning-and-existing-indexes/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/299454/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a table that consumes almost 1.2 TB of space and has lots of historical data which are mostly irrelevant. Since performing bulk DELETE is going to cause a lot of heavy-lifting, I'm trying to use the concept of horizontal partitioning to create multiple partitions, each containing early data (for eg: 2017,2018... 2021) so that I can simply truncate those partitions which is less than an year, so that I can only retain the relevant operational data.&lt;/p&gt;</description></item><item><title>Identify how many CPUs our database server is using</title><link>https://am2.co/2021/09/09/identify-how-many-cpus-our-database-server-is-using/</link><pubDate>Thu, 09 Sep 2021 09:48:47 -0400</pubDate><guid>https://am2.co/2021/09/09/identify-how-many-cpus-our-database-server-is-using/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/300314/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Our server where the Microsoft SQL Server 2016 Web Edition server is installed is running very slow.&lt;/p&gt;&#10;&lt;p&gt;We are thinking of increasing the number of cores licensed on it. However, we need to check how many CPU cores the database is using currently. Our Windows Server 2016 has 16 cores (dual) of CPU.&lt;/p&gt;</description></item><item><title>Is it ok to change drive names/labels (NOT Drive Letters!)</title><link>https://am2.co/2021/09/01/is-it-ok-to-change-drive-names-labels-not-drive-letters/</link><pubDate>Wed, 01 Sep 2021 20:50:32 -0400</pubDate><guid>https://am2.co/2021/09/01/is-it-ok-to-change-drive-names-labels-not-drive-letters/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298926/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I realize this is likely a simplistic question but my searches only return results for Drive Letters or Database names if I include SQL Server. Please feel free to point me to existing articles or answers, and my apologies in advance :)&lt;/p&gt;</description></item><item><title>Azure Data Studio - Intellisense does not detect tables, yet queries work</title><link>https://am2.co/2021/08/23/azure-data-studio-intellisense-does-not-detect-tables-yet-queries-work/</link><pubDate>Mon, 23 Aug 2021 05:08:49 -0400</pubDate><guid>https://am2.co/2021/08/23/azure-data-studio-intellisense-does-not-detect-tables-yet-queries-work/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298402/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I&amp;rsquo;m breaking some new ground and trying to get into Azure Data Studio. I&amp;rsquo;m having a problem with intellisense that seems to be a bug with Azure Data Studio but I&amp;rsquo;m not sure.&lt;/p&gt;&#10;&lt;p&gt;I have issues with basic queries. Foreign keys, select statements and insert statements are all telling me in this example that chocolate_category does not exist, it says it is an invalid object name, or that the foreign key is invalid because the table name is invalid, etcetera.&lt;/p&gt;</description></item><item><title>insert on table being unnaturally slow</title><link>https://am2.co/2021/08/16/insert-on-table-being-unnaturally-slow/</link><pubDate>Mon, 16 Aug 2021 16:45:19 -0400</pubDate><guid>https://am2.co/2021/08/16/insert-on-table-being-unnaturally-slow/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298118/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have an &amp;quot;Basic&amp;quot; pricing tier Azure SQL database with a table of 7 columns, an ID column of int that is the clustered index and primary key, one datetime2(0) column, 3 varchar(100) columns and 2 varchar(MAX) columns, all nullable.&lt;/p&gt;</description></item><item><title>What are the .BCP files inside a .bacpak file?</title><link>https://am2.co/2021/08/16/what-are-the-bcp-files-inside-a-bacpak-file/</link><pubDate>Mon, 16 Aug 2021 15:00:01 -0400</pubDate><guid>https://am2.co/2021/08/16/what-are-the-bcp-files-inside-a-bacpak-file/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298113/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Diving on dba.stackexchange.com I found a &lt;a href="https://dba.stackexchange.com/questions/137993/why-is-a-bacpac-file-so-small-compared-to-a-bak-file-of-the-same-database"&gt;nice answer&lt;/a&gt; that teach me how to open a &lt;code&gt;.bacpac&lt;/code&gt; file with File Explorer.&lt;/p&gt;&#10;&lt;p&gt;I gave it a try with the database &lt;code&gt;AdventureWorks2008R2&lt;/code&gt; and all I did was:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Save the database as &lt;code&gt;.bacpac&lt;/code&gt; file&lt;/li&gt;&#10;&lt;li&gt;Rename the file extension to &lt;code&gt;.zip&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Unzip it&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;And there you go, you can see the tables of the database as folders and inside each folder you can see the raw data.&lt;/p&gt;</description></item><item><title>Job to stop other job at specific time</title><link>https://am2.co/2021/08/13/job-to-stop-other-job-at-specific-time/</link><pubDate>Fri, 13 Aug 2021 11:25:34 -0400</pubDate><guid>https://am2.co/2021/08/13/job-to-stop-other-job-at-specific-time/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298011/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have a job which imports data daily from a remote SQL Server every night, I'll call it Import-Job. Most of the time this job runs through in about 15 minutes and everything is fine but due to a rather unstable VPN connection sometimes the job takes a lot more time.&lt;/p&gt;</description></item><item><title>Getting the first Monday after the third Friday</title><link>https://am2.co/2021/08/12/getting-the-first-monday-after-the-third-friday/</link><pubDate>Thu, 12 Aug 2021 23:48:40 -0400</pubDate><guid>https://am2.co/2021/08/12/getting-the-first-monday-after-the-third-friday/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/297986/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have seen on this site how to get the the third Friday of the month:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weekday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Friday&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datepart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datepart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;How would I get the first Monday after this third Friday?&lt;/p&gt;</description></item><item><title>Why putting SQL Agent offline caused WSFC to fail over on passive node?</title><link>https://am2.co/2021/08/12/why-putting-sql-agent-offline-caused-wsfc-to-fail-over-on-passive-node/</link><pubDate>Thu, 12 Aug 2021 23:17:20 -0400</pubDate><guid>https://am2.co/2021/08/12/why-putting-sql-agent-offline-caused-wsfc-to-fail-over-on-passive-node/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/297983/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have 2 node Windows Failover Cluster with Quorum disk.&#10;SQL agent is NOT a resource of the cluster.&lt;/p&gt;&#10;&lt;p&gt;I needed to enable service broker on the server; for that I need to set SQL Agent offline, run tsql statement then simply put it back online.&lt;/p&gt;</description></item><item><title>Stop using sp_hexadecimal &amp; sp_help_revlogin</title><link>https://am2.co/2021/07/06/dba-serverlogins/</link><pubDate>Tue, 06 Jul 2021 09:00:52 -0400</pubDate><guid>https://am2.co/2021/07/06/dba-serverlogins/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="https://vm.tiktok.com/ZMduBrPEB/" rel="noopener" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/GreenCaterpillar.png" alt="" width="400" height="400" class="size-medium wp-image-8240" /&gt;&lt;/a&gt; Caterpillars transform into beautiful butterflies to realize their full self, much in the same way &lt;code&gt;CONVERT()&lt;/code&gt; changes binary into beautiful hexadecimal strings.&lt;/figure&gt;&#10;&lt;p&gt;Since &lt;a href="https://twitter.com/AMtwo/status/1384126645053771780" rel="noopener" target="_blank"&gt;I started at Stack Overflow&lt;/a&gt;, I&amp;rsquo;ve had the chance to see some of the interesting challenges with running our databases at our scale.&lt;/p&gt;</description></item><item><title>Identify all tables with an identity column</title><link>https://am2.co/2021/07/02/identify-all-tables-with-an-identity-column/</link><pubDate>Fri, 02 Jul 2021 18:04:50 -0400</pubDate><guid>https://am2.co/2021/07/02/identify-all-tables-with-an-identity-column/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/295195/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Is there a query I can run that will show me all tables with an identity column? Trying to figure out if there are any identity based tables whose current identity is nearing upper bound of int32 or int64.&lt;/p&gt;</description></item><item><title>Question Regarding ISDATE Function and DATENAME Functions</title><link>https://am2.co/2021/07/01/question-regarding-isdate-function-and-datename-functions/</link><pubDate>Thu, 01 Jul 2021 23:50:20 -0400</pubDate><guid>https://am2.co/2021/07/01/question-regarding-isdate-function-and-datename-functions/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/295143/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have had an issue this morning with a report failing due to the following error:&lt;/p&gt;&#10;&lt;p&gt;&amp;quot;Conversion failed when converting date and/or time from character string&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;The issue is that in the database we had a value (in a VARCHAR field) of: '31.07/2021'&lt;/p&gt;</description></item><item><title>SQL Server 2012 equivalent of AT TIME ZONE capability</title><link>https://am2.co/2021/06/30/sql-server-2012-equivalent-of-at-time-zone-capability/</link><pubDate>Wed, 30 Jun 2021 22:11:31 -0400</pubDate><guid>https://am2.co/2021/06/30/sql-server-2012-equivalent-of-at-time-zone-capability/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/295079/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Is there a way in SQL Server 2012 to get what the server time zone would be on a particular date/time? In SQL Server 2016, you have &lt;code&gt;AT TIME ZONE&lt;/code&gt;, but that's not available in 2012. I have a &lt;code&gt;datetimeoffset&lt;/code&gt; and I need to convert it to the server's timezone (on that date) before truncating it to &lt;code&gt;datetime&lt;/code&gt;. &lt;code&gt;SWITCHOFFSET&lt;/code&gt; only works if you know the offset, but for servers that change their timezone twice yearly, the offset will flip back and forth.&lt;/p&gt;</description></item><item><title>Why does SQL Server convert floats to scientific notation?</title><link>https://am2.co/2021/06/28/why-does-sql-server-convert-floats-to-scientific-notation/</link><pubDate>Mon, 28 Jun 2021 15:28:50 -0400</pubDate><guid>https://am2.co/2021/06/28/why-does-sql-server-convert-floats-to-scientific-notation/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/294935/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I came across some weird behavior: While passing a float value into a varchar column, the values are getting converted from integers into scientific notation, and it's that scientific notation that gets stored as a string.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;OBJECT_Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tempdb..#whydis&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;begin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;drop&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;OBJECT_Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tempdb..#ImSeriously&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;begin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;drop&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;insert&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;into&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BigID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495591&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495289&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495610&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495611&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495609&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495592&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495686&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BigID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;results look like this:&lt;/p&gt;</description></item><item><title>OLE DB provider "MSOLEDBSQL" with SQL Server not supported?</title><link>https://am2.co/2021/06/28/ole-db-provider-msoledbsql-with-sql-server-not-supported/</link><pubDate>Mon, 28 Jun 2021 15:28:05 -0400</pubDate><guid>https://am2.co/2021/06/28/ole-db-provider-msoledbsql-with-sql-server-not-supported/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/279226/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have been using linked server with the old provider (SQLNCLI) without any issue, as recommended &lt;a href="https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addlinkedserver-transact-sql?view=sql-server-ver15#arguments" rel="noreferrer"&gt;by Microsoft&lt;/a&gt;, I'm planning to switch to new provider (MSOLEDBSQL). I'm able to add linked server using following T-SQL after installing &lt;a href="https://www.microsoft.com/en-us/download/details.aspx?id=56730" rel="noreferrer"&gt;the drivers&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;EXEC&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sp_addlinkedserver&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SQL02\DEV1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;srvproduct&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;MSOLEDBSQL&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;datasrc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SQL02,1933&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Unfortunately, getting following error when I try to query new linked server:&lt;/p&gt;</description></item><item><title>When to partition table in SQL Server based on the amount of memory on server</title><link>https://am2.co/2021/06/25/when-to-partition-table-in-sql-server-based-on-the-amount-of-memory-on-server/</link><pubDate>Fri, 25 Jun 2021 18:12:44 -0400</pubDate><guid>https://am2.co/2021/06/25/when-to-partition-table-in-sql-server-based-on-the-amount-of-memory-on-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/294826/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I understand that table partitioning is mostly done for data management. I understand that table maintenance becomes more difficult for large tables, since e.g. an index rebuild cannot fit in memory or because e.g. sorts scale with O(n*log(n)) and this causes extra problems with large tables.&lt;/p&gt;</description></item><item><title>An expression of non-boolean type specified in a context where a condition is expected, near 'AND'</title><link>https://am2.co/2021/06/08/an-expression-of-non-boolean-type-specified-in-a-context-where-a-condition-is-expected-near-and/</link><pubDate>Tue, 08 Jun 2021 18:45:31 -0400</pubDate><guid>https://am2.co/2021/06/08/an-expression-of-non-boolean-type-specified-in-a-context-where-a-condition-is-expected-near-and/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/293956/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;PROCEDURE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;dbo&lt;/span&gt;&lt;span class="p"&gt;].[&lt;/span&gt;&lt;span class="n"&gt;usp_BaseScan_CycleCount_Report&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;StartDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;EndDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;StartDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;EndDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dbo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CycleCountHistory&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RecordDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BETWEEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;StartDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;EndDate&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ELSE&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dbo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CycleCountHistory&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote&gt;&#10;&lt;p&gt;Error message: Msg 4145, Level 15, State 1, Procedure&#10;usp_BaseScan_CycleCount_Report, Line 16 An expression of non-boolean&#10;type specified in a context where a condition is expected, near 'AND'.&#10;Msg 156, Level 15, State 1, Procedure usp_BaseScan_CycleCount_Report,&#10;Line 21 Incorrect syntax near the keyword 'ELSE'.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>SQL Server Configuration - Disabling the "Allow Remote Connections to this Server" Option</title><link>https://am2.co/2021/06/07/sql-server-configuration-disabling-the-allow-remote-connections-to-this-server-option/</link><pubDate>Mon, 07 Jun 2021 21:16:59 -0400</pubDate><guid>https://am2.co/2021/06/07/sql-server-configuration-disabling-the-allow-remote-connections-to-this-server-option/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/293896/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;My organization had a security audit and was told that we need to DISABLE the &amp;quot;allow remote connection to this server&amp;quot; option for all of our SQL Servers. What impact would this have on connection to the SQL Server via Management Studio (SSMS) from a client machine/desktop or from a web app that might use a connection string or any other external app? All of the documentation I see regarding connectivity issues to a SQL Server seem to include &amp;quot;ENABLING&amp;quot; this option as a solution. Is there a workaround that will allow us to disable it but still allow the access we need from the target clients?&lt;/p&gt;</description></item><item><title>How do I preserve leading zeros for varchar field?</title><link>https://am2.co/2021/05/17/how-do-i-preserve-leading-zeros-for-varchar-field/</link><pubDate>Mon, 17 May 2021 17:00:31 -0400</pubDate><guid>https://am2.co/2021/05/17/how-do-i-preserve-leading-zeros-for-varchar-field/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/291730/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;When saving a number with leading zeros into a string variable or column, leading zeros are truncated.&lt;/p&gt;&#10;&lt;p&gt;When I run this query:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;declare&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;nvarchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;011&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The result I get is 11.&lt;/p&gt;&#10;&lt;p&gt;Is there any way to get 011?&lt;/p&gt;</description></item><item><title>How to convert from nchar to decimal in SQL?</title><link>https://am2.co/2021/05/10/how-to-convert-from-nchar-to-decimal-in-sql/</link><pubDate>Mon, 10 May 2021 18:29:23 -0400</pubDate><guid>https://am2.co/2021/05/10/how-to-convert-from-nchar-to-decimal-in-sql/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/67475843/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have 2 tables(source and destination) which are respectively &lt;code&gt;NOR_LABOR&lt;/code&gt; and &lt;code&gt;ALL_LABOR_DETAILS&lt;/code&gt;. In the source table(&lt;code&gt;NOR_LABOR&lt;/code&gt;) there is a column &lt;code&gt;feet_produced&lt;/code&gt; with the data type &lt;code&gt;nchar(10)&lt;/code&gt;. In the destination table(&lt;code&gt;ALL_LABOR_DETAILS&lt;/code&gt;) there&amp;rsquo;s a column &lt;code&gt;labor_feet_produced&lt;/code&gt; with the data type &lt;code&gt;decimal(18,4)&lt;/code&gt;. I want to convert the &lt;code&gt;feet_produced&lt;/code&gt; from &lt;code&gt;nchar(10)&lt;/code&gt; to &lt;code&gt;decimal(18,4)&lt;/code&gt; and paste it in the &lt;code&gt;ALL_LABOR_DETAILS&lt;/code&gt; table&amp;rsquo;s &lt;code&gt;labor_feet_produced&lt;/code&gt; column.&lt;/p&gt;</description></item><item><title>View SQL Code Behind Flat File Import Wizard?</title><link>https://am2.co/2021/05/10/view-sql-code-behind-flat-file-import-wizard/</link><pubDate>Mon, 10 May 2021 17:58:41 -0400</pubDate><guid>https://am2.co/2021/05/10/view-sql-code-behind-flat-file-import-wizard/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/291326/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Is there a way to view and copy the code that the &amp;quot;Import Flat File to SQL&amp;quot; Wizard ultimately uses, after I have gone through all the steps (chosen file, set up data types for my columns, etc.)?&lt;/p&gt;&#10;&lt;p&gt;While using the Import Flat File to SQL wizard, I found it cumbersome to have to select a data type for each column individually. My data had a large amount of columns to change. In the future, I would prefer doing this via SQL code to save time. I'm learning Microsoft SQL Server Studio and currently only know how to use the Import Flat File Wizard, so I would need to learn all the steps for doing it another way.&lt;/p&gt;</description></item><item><title>Commit or rollback SQLServer-SQLTransaction when no data changed</title><link>https://am2.co/2021/05/07/commit-or-rollback-sqlserver-sqltransaction-when-no-data-changed/</link><pubDate>Fri, 07 May 2021 16:11:54 -0400</pubDate><guid>https://am2.co/2021/05/07/commit-or-rollback-sqlserver-sqltransaction-when-no-data-changed/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/291197/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;we use the &lt;a target="_blank" rel="noopener"&gt;SqlTransaction&lt;/a&gt;-class in the backend to access data stored in the MS-SQLServer.&lt;/p&gt;&#10;&lt;p&gt;In some cases we definitely know that no data were changed by this transaction (and no errors occurred).&#10;So the question is: How to close transactions in these cases?&#10;Shall we use &lt;code&gt;Commit()&lt;/code&gt; or &lt;code&gt;Rollback()&lt;/code&gt;, or none of this both functions or something else?&#10;The aim is to find the most performant way to finish the transaction in a &amp;quot;reasonable&amp;quot; way.&lt;/p&gt;</description></item><item><title>Why is part of transaction committed when stored procedure faults?</title><link>https://am2.co/2021/04/25/why-is-part-of-transaction-committed-when-stored-procedure-faults/</link><pubDate>Sun, 25 Apr 2021 23:31:33 -0400</pubDate><guid>https://am2.co/2021/04/25/why-is-part-of-transaction-committed-when-stored-procedure-faults/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/290443/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a stored procedure that begins by declaring a few variables then contains &lt;code&gt;begin tran;&lt;/code&gt; After this it performs some validations on the supplied arguments (and increments an error count each time a supplied argument fails validation). If there is no error count it then proceeds to carry out 7 inserts. Following this, it has &lt;code&gt;commit tran;&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Cardinality , Parallel Hint alternative for MS-SQL</title><link>https://am2.co/2021/03/31/cardinality-parallel-hint-alternative-for-ms-sql/</link><pubDate>Wed, 31 Mar 2021 10:41:44 -0400</pubDate><guid>https://am2.co/2021/03/31/cardinality-parallel-hint-alternative-for-ms-sql/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/289017/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MARK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ARCHIVE_FLAG&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;N&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;EXISTS&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cm"&gt;/*+ cardinality(S1, 10) parallel(S1,8)*/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SHFASG&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SHIFT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;S1&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;S1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MARKID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ARCHIVE_FLAG&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Y&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is the oracle query that I have, I want to create similar query for my MS SQL DB, Any help please&lt;/p&gt;</description></item><item><title>Job management: How to get the next running date by querying MSDB</title><link>https://am2.co/2020/11/27/job-management-how-to-get-the-next-running-date-by-querying-msdb/</link><pubDate>Fri, 27 Nov 2020 10:10:17 -0500</pubDate><guid>https://am2.co/2020/11/27/job-management-how-to-get-the-next-running-date-by-querying-msdb/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/280429/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Table &lt;code&gt;sysjobschedules&lt;/code&gt; contains 2 columns &lt;code&gt;next_run_date&lt;/code&gt; and &lt;code&gt;next_run_time&lt;/code&gt;. With the help of &lt;code&gt;sysschedules&lt;/code&gt; and column &lt;code&gt;enable&lt;/code&gt; it should be easy to determine the next running date/time of a specific job.&lt;/p&gt;&#10;&lt;p&gt;However, when you change a schedule, &lt;code&gt;sysjobschedules&lt;/code&gt; is only refreshed 20 minutes after alteration by the Sql Server Agent.&lt;/p&gt;</description></item><item><title>log send queue size and redo queue size in AG</title><link>https://am2.co/2020/10/19/log-send-queue-size-and-redo-queue-size-in-ag/</link><pubDate>Mon, 19 Oct 2020 22:44:00 -0400</pubDate><guid>https://am2.co/2020/10/19/log-send-queue-size-and-redo-queue-size-in-ag/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/278324/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to figure out the way to monitor these 2 events&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;p&gt;log send queue size - I can see this in perfmon&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;p&gt;Redo queue size - I can see in dmv but not in perfmon counter&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Is there any way of using perfmon so that I can calculate the redo queue size even thought the counter is not available in perfmon?&lt;/p&gt;</description></item><item><title>Is my VM hyperthreaded?</title><link>https://am2.co/2020/10/18/is-my-vm-hyperthreaded/</link><pubDate>Sun, 18 Oct 2020 23:01:37 -0400</pubDate><guid>https://am2.co/2020/10/18/is-my-vm-hyperthreaded/</guid><description>&lt;p&gt;&lt;a href="https://superuser.com/q/1595400/630094"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I&amp;rsquo;ve been provided a VMware ESXi VM (running Windows Server 2016 SE) with 8 logical processors, but I can&amp;rsquo;t tell whether the VM is hyperthreaded. (This matters for SQL Server.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;C:&lt;/span&gt;&lt;span class="p"&gt;\&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;&lt;span class="p"&gt;\&lt;/span&gt;&lt;span class="n"&gt;XXXXXXX&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;wmic&lt;/span&gt; &lt;span class="n"&gt;CPU&lt;/span&gt; &lt;span class="n"&gt;Get&lt;/span&gt; &lt;span class="n"&gt;DeviceID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;NumberOfCores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;NumberOfLogicalProcessors&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;DeviceID&lt;/span&gt; &lt;span class="n"&gt;NumberOfCores&lt;/span&gt; &lt;span class="n"&gt;NumberOfLogicalProcessors&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;CPU0&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;CPU1&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;CPU2&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;CPU3&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;wmic&lt;/code&gt; says there are four CPUs each with two cores. Does fact that there are two logical processors on each core mean that HT is disabled?&lt;/p&gt;</description></item><item><title>Always On Synchronous Commit Mode With Large Delays</title><link>https://am2.co/2020/10/18/always-on-synchronous-commit-mode-with-large-delays/</link><pubDate>Sun, 18 Oct 2020 11:37:09 -0400</pubDate><guid>https://am2.co/2020/10/18/always-on-synchronous-commit-mode-with-large-delays/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/278257/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;For SQL Server Enterprise's Always On availability groups in Synchronous Commit mode, is there some amount of latency that can't be exceeded? For example, can it work between very distant data centers, such as between the US and Europe?&lt;/p&gt;</description></item><item><title>Replication of only updates and inserts</title><link>https://am2.co/2020/10/14/replication-of-only-updates-and-inserts/</link><pubDate>Wed, 14 Oct 2020 16:01:08 -0400</pubDate><guid>https://am2.co/2020/10/14/replication-of-only-updates-and-inserts/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/278071/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have two sql servers, in the first I want to keep the data from the last three months and in the second I want to keep all the data with the purpose of getting historical reports.&#10;I know how to do a transactional replica but I don't know how to replicate only the inserts and updates, I don't want to replicate the deletions.&lt;/p&gt;</description></item><item><title>sp_update_schedule says @schedule_id does not exist</title><link>https://am2.co/2020/10/06/sp_update_schedule-says-schedule_id-does-not-exist/</link><pubDate>Tue, 06 Oct 2020 12:53:39 -0400</pubDate><guid>https://am2.co/2020/10/06/sp_update_schedule-says-schedule_id-does-not-exist/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/276609/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I wrote a script that reads job schedules from &lt;code&gt;msdb.dbo.sysschedules&lt;/code&gt; and runs &lt;code&gt;sp_update_schedule&lt;/code&gt; to change the &lt;code&gt;active_start_time&lt;/code&gt; for a given subset of jobs. In each case, &lt;code&gt;sp_update_schedule&lt;/code&gt; fails with the message &amp;quot;The specified @schedule_id('xxx') does not exist&amp;quot;. (MessageID 14262, Severity 16)&lt;/p&gt;</description></item><item><title>Multi-subnet availability group, with mixed MultiSubnetFailover support (Part 2)</title><link>https://am2.co/2020/10/06/multi-subnet-registerallprovidersip-2/</link><pubDate>Tue, 06 Oct 2020 08:00:55 -0400</pubDate><guid>https://am2.co/2020/10/06/multi-subnet-registerallprovidersip-2/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=6U0C3LOwEP0"&gt;&lt;img src="https://am2.co/wp-content/uploads/AGListener01-b.jpg" alt="" width="512" height="315" class="alignright size-large wp-image-4885" /&gt;&lt;/a&gt;&#10;In &lt;a href="https://am2.co/2020/10/05/multi-subnet-registerallprovidersip-1/"&gt;yesterday&amp;rsquo;s post&lt;/a&gt;, I showed how to configure an availability group (AG) to use the &lt;code&gt;RegisterAllProvidersIP=0&lt;/code&gt; when you can&amp;rsquo;t get clients to connect using the &lt;code&gt;MultiSubnetFailover=true&lt;/code&gt; connection string attribute.&lt;/p&gt;&#10;&lt;p&gt;I mentioned that you have to make some trade-offs when you set &lt;code&gt;RegisterAllProvidersIP=0&lt;/code&gt;, and included this comparison:&lt;/p&gt;</description></item><item><title>Multi-subnet availability group, without MultiSubnetFailover support (Part 1)</title><link>https://am2.co/2020/10/05/multi-subnet-registerallprovidersip-1/</link><pubDate>Mon, 05 Oct 2020 09:00:48 -0400</pubDate><guid>https://am2.co/2020/10/05/multi-subnet-registerallprovidersip-1/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=jj8rmh8tna8"&gt;&lt;img src="https://am2.co/wp-content/uploads/AGListener01-a.jpg" alt="" width="512" height="315" class="alignright size-large wp-image-4885" /&gt;&lt;/a&gt;&#10;As a DBA, we have the opportunity &amp;amp; responsibility to build highly available database platforms for use by applications &amp;amp; users. Even if you are a DBA at a small company supporting databases for only internal applications, we are usually still responsible for providing databases as a service for application teams. Sometimes, in order for us to provide the best service, we need application teams to do some work to make use of the super awesome thing we built. And sometimes, getting application teams to make that change isn&amp;rsquo;t easy, or isn&amp;rsquo;t fast, or isn&amp;rsquo;t even possible.&lt;/p&gt;</description></item><item><title>Microsoft Azure hack for social justice</title><link>https://am2.co/2020/10/04/microsoft-azure-hack-for-social-justice/</link><pubDate>Sun, 04 Oct 2020 11:00:33 -0400</pubDate><guid>https://am2.co/2020/10/04/microsoft-azure-hack-for-social-justice/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:512px"&gt;&lt;a href="https://socialjusticehack.devpost.com/"&gt;&lt;img src="https://am2.co/wp-content/uploads/cody-pulliam-GGKVGSkKIzM-unsplash.jpg" alt="" width="512" height="342" class="size-large wp-image-4895" /&gt;&lt;/a&gt; &lt;a href="https://unsplash.com/photos/GGKVGSkKIzM"&gt;Photo via unsplash&lt;/a&gt;&lt;/figure&gt;&#10;&lt;p&gt;Microsoft is going to be running a virtual hackathon, running from October 12 through November 20. The theme of the hack will be to use Microsoft Azure to address some social justice issue. I&amp;rsquo;m thrilled to be joining &lt;a href="https://socialjusticehack.devpost.com/#judges" rel="noopener noreferrer" target="_blank"&gt;the judging panel&lt;/a&gt; for this event, which is at the intersection of two of my greatest passions&amp;ndash;social justice and technology.&lt;/p&gt;</description></item><item><title>Can we enable tls 1.0 on MSSQL Server 2019 on database level? if yes then how?</title><link>https://am2.co/2020/09/25/can-we-enable-tls-1-0-on-mssql-server-2019-on-database-level-if-yes-then-how/</link><pubDate>Fri, 25 Sep 2020 20:40:09 -0400</pubDate><guid>https://am2.co/2020/09/25/can-we-enable-tls-1-0-on-mssql-server-2019-on-database-level-if-yes-then-how/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/276113/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;i am running sql server 2019 on Linux box and trying to connect using a Windows server 2016 client, how can we enable TLS 1.0 for SQL Server 2019 on the Database/instance level.&lt;/p&gt;&#10;&lt;p&gt;TIA.&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/276113/52344" rel="noopener" target="_blank"&gt;2020-09-25&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;Rafay Pervaiz&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;h2 id="tldr"&gt;TLDR&lt;/h2&gt;&#10;&lt;p&gt;You don't.&lt;/p&gt;</description></item><item><title>SQL Server 2019 Database stuck In Recovery state after restart</title><link>https://am2.co/2020/09/23/sql-server-2019-database-stuck-in-recovery-state-after-restart/</link><pubDate>Wed, 23 Sep 2020 07:44:23 -0400</pubDate><guid>https://am2.co/2020/09/23/sql-server-2019-database-stuck-in-recovery-state-after-restart/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/275934/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;SQL Server was restarted by mistake, when it came online, database came back in &amp;quot;In Recovery&amp;quot; mode.&lt;/p&gt;&#10;&lt;p&gt;Check from error it says &amp;quot;Recovery of database 'DB1' (5) is 8% complete (approximately 27146 seconds remain). Phase 2 of 3. This is an informational message only. No user action is required.&lt;/p&gt;</description></item><item><title>How to dig deeper into ASYNC_NETWORK_IO waits</title><link>https://am2.co/2020/08/15/how-to-dig-deeper-into-async_network_io-waits/</link><pubDate>Sat, 15 Aug 2020 00:48:17 -0400</pubDate><guid>https://am2.co/2020/08/15/how-to-dig-deeper-into-async_network_io-waits/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/273788/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I've been handed a graph that comes from SolarWinds showing top wait events broken down by day. The last 2 days there's a part of the daily color coded bar representing a total of 3 hours for ASYNC_NETWORK_IO. Still trying to see if I can get access to Solar Winds panels to try and see if it offers a drill down into the graph or not.&lt;/p&gt;</description></item><item><title>Tech Community Equality Index</title><link>https://am2.co/2020/06/24/tech-community-equality-index/</link><pubDate>Wed, 24 Jun 2020 05:00:19 -0400</pubDate><guid>https://am2.co/2020/06/24/tech-community-equality-index/</guid><description>&lt;style&gt;&#10; table {&#10; border-collapse: collapse;&#10; width: 100%;&#10; caption-side: bottom !important;&#10; }&#10; tr:nth-child(even) {background-color: #F2F7DF;}&#10;&lt;/style&gt;&#10;&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=nCS7Rus4_-Y" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/photo-of-a-person-wearing-printed-crew-neck-t-shirt-2769325-1024x576.jpg" alt="" width="512" height="288" class="alignright size-large wp-image-3659" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Over the last weeks &amp;amp; months, I&amp;rsquo;ve had an increasing number of conversations with folks on the topics of diversity, inclusion, equality, and justice. These discussions we have with coworkers, members of the data community, family and friends are all valuable, and help us look at life in a different, more inclusive way.&lt;/p&gt;</description></item><item><title>Remove/suppress dashes from "Results to Text" output in SSMS?</title><link>https://am2.co/2020/06/15/remove-suppress-dashes-from-results-to-text-output-in-ssms/</link><pubDate>Mon, 15 Jun 2020 06:58:39 -0400</pubDate><guid>https://am2.co/2020/06/15/remove-suppress-dashes-from-results-to-text-output-in-ssms/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/269165/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;(This is just a "reproducer", not the real code, because that's long and complicated.)&lt;/p&gt;&#10;&lt;p&gt;The output of&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NOCOUNT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@@&lt;/span&gt;&lt;span class="n"&gt;SERVICENAME&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@@&lt;/span&gt;&lt;span class="k"&gt;version&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;is:&lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10;-----------------------------------------------------------------------------&#10;MSSQLSERVER&#10;&lt;hr&gt;&#10;&lt;p&gt;Microsoft SQL Server 2014 (SP3-CU4) (KB4500181) - 12.0.6329.1 (X64)&#10;Jul 20 2019 21:42:29&#10;Copyright (c) Microsoft Corporation&#10;Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 &amp;lt;X64&amp;gt; (Build 9600: ) (Hypervisor)&lt;/p&gt;&#10;&lt;/div&gt;</description></item><item><title>Why the instance name of SQL Server Express is changing?</title><link>https://am2.co/2020/05/21/why-the-instance-name-of-sql-server-express-is-changing/</link><pubDate>Thu, 21 May 2020 08:12:15 -0400</pubDate><guid>https://am2.co/2020/05/21/why-the-instance-name-of-sql-server-express-is-changing/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/267593/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm working on a web app which is using &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10; &lt;p&gt;SQL Server Express (Microsoft SQL Server 2016 (SP1) (KB3182545) -&#10; 13.0.4001.0 (X64) Oct 28 2016 18:17:30 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 6.3 &#10; (Build 18362: )).&lt;/p&gt;&#10;&lt;/div&gt;</description></item><item><title>Recursive CTE in SQL Server to count blocking sessions</title><link>https://am2.co/2020/05/18/recursive-cte-in-sql-server-to-count-blocking-sessions/</link><pubDate>Mon, 18 May 2020 19:54:25 -0400</pubDate><guid>https://am2.co/2020/05/18/recursive-cte-in-sql-server-to-count-blocking-sessions/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/72295228/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I&amp;rsquo;m trying to make CTE to count blocking sessions on server. Currently I made a function to do so(returns blocking session amount). But still could not write this query with CTE.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FUNCTION&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dbo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SESSIONS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="k"&gt;SESSION&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;RETURNS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DECLARE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;&#9;&#9;&#9;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&#9;&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;isNULL&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&#9;&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dm_exec_requests&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;R2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;blocking_session_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;R1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blocking_session_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;BLOCKING&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&#9;&lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dm_exec_requests&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;r1&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;blocking_session_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;R3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&#9;&lt;/span&gt;&lt;span class="k"&gt;GROUP&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;blocking_session_id&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&#9;&lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dm_exec_sessions&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;R3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="o"&gt;=@&lt;/span&gt;&lt;span class="k"&gt;SESSION&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&lt;/span&gt;&lt;span class="k"&gt;DECLARE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dm_exec_requests&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&#9; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;blocking_session_id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="k"&gt;SESSION&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&lt;/span&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&#9;&lt;/span&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dbo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SESSIONS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &#9;&lt;/span&gt;&lt;span class="k"&gt;RETURN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;returnValue&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://stackoverflow.com/q/72295228/1948808" rel="noopener" target="_blank"&gt;2022-05-18&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://stackoverflow.com/users/4715808" rel="noopener" target="_blank"&gt;mortu&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Find the SQL Server service account with sys.dm_server_services</title><link>https://am2.co/2020/05/12/find-the-sql-server-service-account-with-sys-dm_server_services/</link><pubDate>Tue, 12 May 2020 09:00:56 -0400</pubDate><guid>https://am2.co/2020/05/12/find-the-sql-server-service-account-with-sys-dm_server_services/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:384px"&gt;&lt;a href="https://www.youtube.com/watch?v=oxYiYApx_F8" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/HappyCallie-768x1024.jpg" alt="" width="384" height="512" class="alignright size-large wp-image-3012" /&gt;&lt;/a&gt; This is &lt;a href="https://twitter.com/CalliePie" rel="noopener noreferrer" target="_blank"&gt;Callie&lt;/a&gt;. She has nothing to do with DMVs, but isn't she cute?!&lt;/figure&gt;&#10;&lt;p&gt;SQL Server 2005 introduced &lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/system-dynamic-management-views" rel="noopener noreferrer" target="_blank"&gt;Dynamic Management Views(DMVs)&lt;/a&gt;. Technically, there are both views &amp;amp; functions&amp;ndash;DMVs &amp;amp; DMFs, but colloquially they&amp;rsquo;re often simply referred to as just &amp;ldquo;DMVs&amp;rdquo;. DMVs simply return information about the state of the server or database and can be used for monitoring and troubleshooting of server/database health &amp;amp; performance.&lt;/p&gt;</description></item><item><title>Making non-SARGable queries seek, without changing the query</title><link>https://am2.co/2020/05/06/making-non-sargable-queries-seek-without-changing-the-query/</link><pubDate>Wed, 06 May 2020 08:36:27 -0400</pubDate><guid>https://am2.co/2020/05/06/making-non-sargable-queries-seek-without-changing-the-query/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=tALDcVmWE9w" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/sarg-pubs-featured-1024x577.png" alt="" width="512" height="289" class="alignright size-large wp-image-3253" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;We&amp;rsquo;ve all been there. You&amp;rsquo;ve got a query where the &lt;code&gt;JOIN&lt;/code&gt; or &lt;code&gt;WHERE&lt;/code&gt; predicate is not &lt;a href="https://dba.stackexchange.com/a/217983/52344" rel="noopener noreferrer" target="_blank"&gt;SARGable&lt;/a&gt;. You&amp;rsquo;ve read about how &lt;a href="https://www.erikdarlingdata.com/2019/04/slightly-less-not-sargable/" rel="noopener noreferrer" target="_blank"&gt;this can be a problem&lt;/a&gt;, and &lt;a href="https://www.erikdarlingdata.com/2019/04/slightly-less-not-sargable/" rel="noopener noreferrer" target="_blank"&gt;how bad it is for performance&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Alas, you cannot change the query. Sometimes this reason is political, sometimes it&amp;rsquo;s because you&amp;rsquo;ve got a third-party app and simply don&amp;rsquo;t have access to the code. But you do have access to the database&amp;hellip;&lt;/p&gt;</description></item><item><title>Replication latency when an Availability Group replica is offline</title><link>https://am2.co/2020/05/04/replication-latency-when-an-availability-group-replica-is-offline/</link><pubDate>Mon, 04 May 2020 10:02:52 -0400</pubDate><guid>https://am2.co/2020/05/04/replication-latency-when-an-availability-group-replica-is-offline/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=w0nNbs8ldGY" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/stormtrooper-1343772_1920-1024x529.jpg" alt="" width="512" height="265" class="alignright size-large wp-image-3224" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Assume you have configured a transactional replication publisher, which is part of an availability group (AG). Now, you have an asynchronous secondary AG (or mirroring) replica that is offline. Perhaps this is a DR node, and you are doing patching or other planned maintenance on that DR node, with it intentionally offline.&lt;/p&gt;</description></item><item><title>Stop trying to shrink tempdb files</title><link>https://am2.co/2020/04/28/stop-trying-to-shrink-tempdb/</link><pubDate>Tue, 28 Apr 2020 09:00:24 -0400</pubDate><guid>https://am2.co/2020/04/28/stop-trying-to-shrink-tempdb/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:455px"&gt;&lt;a href="https://ShouldIShrinkMyDatabase.com"&gt;&lt;img src="https://am2.co/wp-content/uploads/black-and-white-cat-1317844-910x1024.jpg" alt="" width="341" height="384" class="size-large wp-image-3090" /&gt;&lt;/a&gt; Every time someone shrinks a database, a kitten dies. &lt;/figure&gt;&#10;&lt;h2 id="stop-shrinking-your-tempdb-data-files"&gt;Stop shrinking your tempdb data files&lt;/h2&gt;&#10;&lt;p&gt;I recently wrote about &lt;a href="https://am2.co/2020/04/21/fixing-tempdb/"&gt;growing, shrinking, and removing tempdb files&lt;/a&gt;. In that article I explained that SQL Server won&amp;rsquo;t move a page that contains an internal worktable object, and thus trying to shrink tempdb files can be futile. Today, I&amp;rsquo;m going to explain how attempting to shrink tempdb files can actually be harmful.&lt;/p&gt;</description></item><item><title>Fixing tempdb: Growing, shrinking, and removing data files</title><link>https://am2.co/2020/04/21/fixing-tempdb/</link><pubDate>Tue, 21 Apr 2020 09:00:37 -0400</pubDate><guid>https://am2.co/2020/04/21/fixing-tempdb/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:500px"&gt;&lt;a href="https://www.youtube.com/watch?v=RaCodgL9cvk"&gt;&lt;img src="https://am2.co/wp-content/uploads/drop-files-here-extra.jpg" alt="" width="500" height="224" class="size-full wp-image-3070" /&gt;&lt;/a&gt; Dropping tempdb files like they're hot&lt;/figure&gt;&#10;&lt;p&gt;I recently came across a server where &lt;code&gt;tempdb&lt;/code&gt; was breaking all the rules.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&#9;&lt;li&gt;Data files were all different sizes. I want all data files to be the same size so that proportional fill uses them evenly.&lt;/li&gt;&#10;&#9;&lt;li&gt;There were 10 &lt;code&gt;tempdb&lt;/code&gt; files, with 8 files on a dedicated disk, and 2 on a slower disk shared with other data files. And free space was sky high, so the extra files aren't needed anymore! (They were probably added to fix a short-term emergency, and never cleaned up.)&lt;/li&gt;&#10;&#9;&lt;li&gt;The log file was tiny, and didn't have room to grow. For a 500GB tempdb, the log file was only 4GB!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="three-fixes"&gt;Three fixes&lt;/h2&gt;&#10;&lt;p&gt;There are three problems I&amp;rsquo;ve got to fix. I need to (1) remove those two extra files, (2) grow the &lt;code&gt;tempdb&lt;/code&gt; log file, and (3) even out the size of the data files (and shrink them a little to make room for the larger log file. We&amp;rsquo;re going to tackle these in the reverse order than I listed them&amp;ndash;partially out of necessity, and partially because it&amp;rsquo;s going to be easier.&lt;/p&gt;</description></item><item><title>Should I install SSMS on a server running SQL Server?</title><link>https://am2.co/2020/04/14/should-i-install-ssms-on-a-server-running-sql-server/</link><pubDate>Tue, 14 Apr 2020 09:00:27 -0400</pubDate><guid>https://am2.co/2020/04/14/should-i-install-ssms-on-a-server-running-sql-server/</guid><description>&lt;p&gt;&lt;a href="https://youtu.be/jdM02PYzimU?t=40"&gt;&lt;img src="https://am2.co/wp-content/uploads/RDP.jpg" alt="" width="500" height="500" class="alignright size-full wp-image-3007" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;There&amp;rsquo;s a lot of advice out there on the internet that suggests that you should not install SSMS on your database servers running SQL Server.&lt;/p&gt;&#10;&lt;p&gt;This came up at work recently, where I was asked &amp;ldquo;Should we install SSMS on our database servers?&amp;rdquo; and my answer is:&lt;/p&gt;</description></item><item><title>Can changing database owner affect permissions or role memberships?</title><link>https://am2.co/2020/03/30/can-changing-database-owner-affect-permissions-or-role-memberships/</link><pubDate>Mon, 30 Mar 2020 21:23:49 -0400</pubDate><guid>https://am2.co/2020/03/30/can-changing-database-owner-affect-permissions-or-role-memberships/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/263956/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;A couple years ago we ran into a situation where we were changing the database owner from a DBA's login to sa, and immediately thereafter we received a complaint that the service login (which was NOT the DBA's login) no longer had access to the database. On checking, the service login had indeed lost it's role memberships. &lt;/p&gt;</description></item><item><title>When STRING_SPLIT() falls short</title><link>https://am2.co/2020/03/20/when-string_split-falls-short/</link><pubDate>Fri, 20 Mar 2020 10:00:54 -0400</pubDate><guid>https://am2.co/2020/03/20/when-string_split-falls-short/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="https://www.youtube.com/watch?v=vY1TQ9pb2J4"&gt;&lt;img src="https://am2.co/wp-content/uploads/STONE_SPLIT.jpg" alt="" width="400" height="300" class="size-medium wp-image-2828" /&gt;&lt;/a&gt; &lt;a href="https://twitter.com/AaronBertrand" rel="noopener noreferrer" target="_blank"&gt;Aaron&lt;/a&gt; attempting a STONE_SPLIT at a recent curling competition.&lt;/figure&gt;&#10;This morning, my friend Aaron Bertrand (&lt;a href="http://sqlblog.org" rel="noopener noreferrer" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/AaronBertrand" rel="noopener noreferrer" target="_blank"&gt;twitter&lt;/a&gt;) posted &lt;a href="https://sqlperformance.com/2020/03/t-sql-queries/please-help-string-split-improvements" rel="noopener noreferrer" target="_blank"&gt;a plea for help with &lt;code&gt;STRING_SPLIT()&lt;/code&gt; improvements&lt;/a&gt;. I'm very much in Aaron's corner on this, having &lt;a href="https://am2.co/2015/04/21/converting-delimited-values-to-a-table-efficiently/" rel="noopener noreferrer" target="_blank"&gt;written about the olden days myself&lt;/a&gt;. &#10;&lt;h3&gt;Why &lt;code&gt;STRING_SPLIT()&lt;/code&gt; is supposed to be awesome&lt;/h3&gt;&#10;CLR was fast, but inaccessible to many DBAs. XML was almost as good, but ugh, XML. And multi-statement table valued functions are evil but prevalent. &#10;&lt;p&gt;&lt;code&gt;STRING_SPLIT()&lt;/code&gt; promised to be both super fast, and lift the code maintenance problem for DBAs who don&amp;rsquo;t know .NET and struggle with the crazy XML syntax.&lt;/p&gt;</description></item><item><title>MS SQL Express 2016 on Amazon AWS: I Can Take Database Offline but Can't Bring It Online</title><link>https://am2.co/2020/03/01/ms-sql-express-2016-on-amazon-aws-i-can-take-database-offline-but-cant-bring-it-online/</link><pubDate>Sun, 01 Mar 2020 10:59:06 -0500</pubDate><guid>https://am2.co/2020/03/01/ms-sql-express-2016-on-amazon-aws-i-can-take-database-offline-but-cant-bring-it-online/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/260928/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I can take databases offline (via GUI) but can't bring them back online. The server details are as follow:&lt;/p&gt;&#10;&lt;p&gt;RDBMS: MS SQL 2016 Express&#10;Host: Amazon AWS/RDS Free Tier&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Details/History of the Problem&lt;/strong&gt;&#10;A few months ago, I created a db instance on Amazon AWS and at the time of creation, the 'master/admin' account was setup via the AWS/RDS web page. With this 'admin' account, I have created several databases on that instance without any problems.&lt;/p&gt;</description></item><item><title>How to store real-time data to database</title><link>https://am2.co/2020/02/23/how-to-store-real-time-data-to-database/</link><pubDate>Sun, 23 Feb 2020 18:38:30 -0500</pubDate><guid>https://am2.co/2020/02/23/how-to-store-real-time-data-to-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/260351/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Here is my situation:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;I have a WebSocket connection that feeds me data real-time&lt;/li&gt;&#10;&lt;li&gt;I have an async callback function that gets the data and inserts into a queue &lt;/li&gt;&#10;&lt;li&gt;I have another thread that reads from the queue and stores it into the Postgres database, one row at a time (using python's psycopg2 library)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The problem is the real-time data comes in faster than the time it takes to insert into the database, and in a couple of hours, the server runs out of memory. (Is this because psycopg2 library is slow?)&lt;/p&gt;</description></item><item><title>Is it possible for master, tempdb, model and msdb to have a database_id other than 1,2,3,4 respectively?</title><link>https://am2.co/2020/02/12/is-it-possible-for-master-tempdb-model-and-msdb-to-have-a-database_id-other-than-1234-respectively/</link><pubDate>Wed, 12 Feb 2020 12:25:11 -0500</pubDate><guid>https://am2.co/2020/02/12/is-it-possible-for-master-tempdb-model-and-msdb-to-have-a-database_id-other-than-1234-respectively/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/259510/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;SQL Server &lt;a target="_blank" rel="noopener"&gt;System Databases&lt;/a&gt;, as far as I know, always have those same IDs and I have seen lots of maintenance scripts on the internet relying on the predicate &lt;code&gt;WHERE database_id &amp;gt; 4&lt;/code&gt; to exclude them from the actions of the script.&lt;/p&gt;</description></item><item><title>Fastest way to shrink LOB data in SQL Server</title><link>https://am2.co/2020/01/16/fastest-way-to-shrink-lob-data-in-sql-server/</link><pubDate>Thu, 16 Jan 2020 07:00:12 -0500</pubDate><guid>https://am2.co/2020/01/16/fastest-way-to-shrink-lob-data-in-sql-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/257512/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have a database of total size of 3886 GB. Out of which 778 GB is free. So total 3108 GB worth of data is present.&lt;/p&gt;&#10;&lt;p&gt;Out of which 2458 GB is "LOB Data" and 400 GB is worth "Regular".&lt;/p&gt;</description></item><item><title>Job waiting on CXCONSUMER</title><link>https://am2.co/2020/01/09/job-waiting-on-cxconsumer/</link><pubDate>Thu, 09 Jan 2020 12:09:54 -0500</pubDate><guid>https://am2.co/2020/01/09/job-waiting-on-cxconsumer/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/257011/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have got a procedure on SQL Server agent jobs and this job started to hang on transaction for many hours with wait stats CXCONSUMER and never complete. The problem is after we noticed that it was hanging we kill the job and started manually during and the job was working fine and completing. But right now neither starting manually or on sql agent job seems never completing and hanging on waits with CXCONSUMER. &lt;/p&gt;</description></item><item><title>Blocking with OBJECT_NAME()</title><link>https://am2.co/2019/12/24/blocking-with-object_name/</link><pubDate>Tue, 24 Dec 2019 10:38:36 -0500</pubDate><guid>https://am2.co/2019/12/24/blocking-with-object_name/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:512px"&gt;&lt;a href="https://www.youtube.com/watch?v=bphPp8k9aZo"&gt;&lt;img src="https://am2.co/wp-content/uploads/berkay-gumustekin-ngqyo2AYYnE-unsplash-1024x683.jpg" alt="" width="512" height="341" class="size-large wp-image-2392" /&gt;&lt;/a&gt; Doggos increase blog readership by 140%. 14/10. They are good doggos.&lt;/figure&gt;&#10;&lt;p&gt;As a DBA, you probably use the &lt;code&gt;OBJECT_NAME()&lt;/code&gt; function quite a bit. I know I do. If you aren&amp;rsquo;t familiar with it, you can read &lt;a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/object-name-transact-sql?view=sql-server-ver15" rel="noopener noreferrer" target="_blank"&gt;the documentation&lt;/a&gt; if you want, but it&amp;rsquo;s a pretty straightforward function that converts object IDs into object names.&lt;/p&gt;</description></item><item><title>Do triggers start to degrade in performance (or sometimes fail) on highly transactional tables?</title><link>https://am2.co/2019/12/21/do-triggers-start-to-degrade-in-performance-or-sometimes-fail-on-highly-transactional-tables/</link><pubDate>Sat, 21 Dec 2019 02:41:00 -0500</pubDate><guid>https://am2.co/2019/12/21/do-triggers-start-to-degrade-in-performance-or-sometimes-fail-on-highly-transactional-tables/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/256083/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;How many transactions per second can SQL Server table triggers handle? If I had a highly transactional table that was inserted into 1,000 times a second, are insert triggers on that table reliable to fire every single time?&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/256083/52344" rel="noopener" target="_blank"&gt;2019-12-21&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/150011" rel="noopener" target="_blank"&gt;J.D.&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>What the heck is the dbcreator role?</title><link>https://am2.co/2019/12/19/what-the-heck-is-the-dbcreator-role/</link><pubDate>Thu, 19 Dec 2019 07:30:14 -0500</pubDate><guid>https://am2.co/2019/12/19/what-the-heck-is-the-dbcreator-role/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=7UbY3lmCSb0"&gt;&lt;img src="https://am2.co/wp-content/uploads/ksenia-makagonova-HP9nSjikXq0-unsplash-1024x683.jpg" alt="" width="512" height="342" class="alignright size-large wp-image-2251" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/server-level-roles?view=sql-server-ver15#fixed-server-level-roles" rel="noopener noreferrer" target="_blank"&gt;Microsoft docs&lt;/a&gt; defines the dbcreator role as:&lt;/p&gt;&#10;&lt;blockquote&gt;Members of the dbcreator fixed server role can create, alter, drop, and restore any database.&lt;/blockquote&gt;&#10;&lt;p&gt;But what specific permissions are actually included in that role? If we scroll down in the docs just a little, we&amp;rsquo;ll see a diagram that tells us that &lt;code&gt;dbcreator&lt;/code&gt; grants two permissions:&lt;/p&gt;</description></item><item><title>Testing as another user...without their password</title><link>https://am2.co/2019/12/18/testing-as-another-user-without-their-password/</link><pubDate>Wed, 18 Dec 2019 11:50:35 -0500</pubDate><guid>https://am2.co/2019/12/18/testing-as-another-user-without-their-password/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:512px"&gt;&lt;a href="https://www.youtube.com/watch?v=6AXd5tcyneE"&gt;&lt;img src="https://am2.co/wp-content/uploads/greg-ortega-1LCzr14Ah5U-unsplash-1024x684.jpg" alt="" width="512" height="342" class="size-large wp-image-2381" /&gt;&lt;/a&gt; This guy doesn't have Elvis's password and is still able to impersonate him.&lt;/figure&gt;&#10;As a DBA or SQL Developer, you've surely encountered a scenario where something worked for you, but not for another user. DBAs usually are part of the sysadmin role, or have a collection of powerful permissions. If I run code as myself, I will *never* have permissions problems because my account is sysadmin. If I want to ensure permissions are correct, I need to run the code as the less-privileged account. &#10;&lt;h2 id="can-you-try-now"&gt;Can you try now?&lt;/h2&gt;&#10;&lt;h3 id="can-you-try-now-1"&gt;Can you try now?&lt;/h3&gt;&#10;&lt;h4 id="can-you-try-now-2"&gt;Can you try now?&lt;/h4&gt;&#10;&lt;h5 id="can-you-try-now-3"&gt;Can you try now?&lt;/h5&gt;&#10;&lt;p&gt;I honestly don&amp;rsquo;t think there is a more frustrating experience than getting into the feedback loop of making a permission change, and asking the user if it works, and when it doesn&amp;rsquo;t work, you try another change, and ask them to try again, and when it doesn&amp;rsquo;t work, you try another change, and ask them to try again, and when it doesn&amp;rsquo;t work, you try another change, and ask them to try again, and when it doesn&amp;rsquo;t work, you try another change, and ask them to try again&amp;hellip;&lt;/p&gt;</description></item><item><title>I hate sp_estimate_data_compression_savings</title><link>https://am2.co/2019/12/17/i-hate-sp_estimate_data_compression_savings/</link><pubDate>Tue, 17 Dec 2019 10:55:26 -0500</pubDate><guid>https://am2.co/2019/12/17/i-hate-sp_estimate_data_compression_savings/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=-fQGPZTECYs" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/Slinky-1024x1024.jpg" alt="" width="400" height="400" class="alignright size-large wp-image-2380" /&gt;&lt;/a&gt;&#10;If you&amp;rsquo;re working with compressed indexes, SQL Server provides &lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-estimate-data-compression-savings-transact-sql?view=sql-server-ver15" rel="noopener noreferrer" target="_blank"&gt;a system stored procedure&lt;/a&gt; to help test the space savings of implementing data compression: &lt;code&gt;sp_estimate_data_compression_savings&lt;/code&gt;. Starting in SQL Server 2019, &lt;a href="http://www.nikoport.com/2018/09/27/columnstore-indexes-part-125-estimate-columnstore-compression-as-a-system-stored-proc/" rel="noopener noreferrer" target="_blank"&gt;it can even be used to estimate savings with columnstore&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;I really don&amp;rsquo;t like &lt;code&gt;sp_estimate_data_compression_savings&lt;/code&gt;. In fact, I kind of hate it. It&amp;rsquo;s not always very accurate&amp;ndash;and even when it is accurate, the results can be misleading. Before I get ranty about why I don&amp;rsquo;t like it, let&amp;rsquo;s look at it in action.&lt;/p&gt;</description></item><item><title>INSERT EXEC statement cannot be nested</title><link>https://am2.co/2019/12/13/insert-exec-statement-cannot-be-nested/</link><pubDate>Fri, 13 Dec 2019 23:16:21 -0500</pubDate><guid>https://am2.co/2019/12/13/insert-exec-statement-cannot-be-nested/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/255615/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a stored proc spGetSites that returns three columns for SiteName, SiteId and UnitCount. The stored proc runs perfectly fine. &#10;I'm trying to store the results of the stored proc to a temp table @Site to use for my report with below syntax. This time I got an error message: "INSERT EXEC statement cannot be nested"&lt;/p&gt;</description></item><item><title>Changing a column from int to bigint, without downtime</title><link>https://am2.co/2019/12/11/changing-a-column-from-int-to-bigint-without-downtime/</link><pubDate>Wed, 11 Dec 2019 08:00:41 -0500</pubDate><guid>https://am2.co/2019/12/11/changing-a-column-from-int-to-bigint-without-downtime/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=YHKGUu2gaOg" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/AlterOnline2.png" alt="" width="481" height="396" class="alignright size-full wp-image-2359" /&gt;&lt;/a&gt;&#10;Changing a column from &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;bigint&lt;/code&gt; has gotten a lot easier since I started working on SQL Server back at the turn of the century. SQL Server 2016 introduced the ability to do &lt;code&gt;ALTER TABLE...ALTER COLUMN&lt;/code&gt; as an online operation using the &lt;code&gt;WITH (ONLINE=ON)&lt;/code&gt; syntax in Enterprise Edition. This wonderful syntax now allows you to alter a column from &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;bigint&lt;/code&gt; without causing major blocking. The &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;bigint&lt;/code&gt; conversion is one of the most popular data type changes I see&amp;ndash;A developer inevitably creates the table thinking they will never have more than 2 billion rows&amp;hellip; then some years or months later 2 billion becomes a reality.&lt;/p&gt;</description></item><item><title>How to see restore history of a deleted database?</title><link>https://am2.co/2019/11/23/how-to-see-restore-history-of-a-deleted-database/</link><pubDate>Sat, 23 Nov 2019 21:33:37 -0500</pubDate><guid>https://am2.co/2019/11/23/how-to-see-restore-history-of-a-deleted-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/253996/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;For example, I had a database and I want to see which physical backup file was used to restore into it. The problem is that the database was deleted. How can I see the record?&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/253996/52344" rel="noopener" target="_blank"&gt;2019-11-23&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/174155" rel="noopener" target="_blank"&gt;sql-noob&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;p&gt;Depending on how the database was dropped, your luck will vary considerably.&lt;/p&gt;</description></item><item><title>Can't use GitKraken on private repositories</title><link>https://am2.co/2019/11/08/stack-overflow-template/</link><pubDate>Fri, 08 Nov 2019 12:03:21 -0500</pubDate><guid>https://am2.co/2019/11/08/stack-overflow-template/</guid><description>&lt;p&gt;&lt;a href="https://superuser.com/q/1500265/630094"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I&amp;rsquo;ve been using GitKraken for a while now, since about May of this year and it never gave me any trouble, except for now. I was working on a school project and GitKraken now prevents me from opening its repository, because, apparently, this is now a Pro feature, although, I have a Github Pro account, which I use to login in Gitkraken, so, I should have access to Pro features, but I don&amp;rsquo;t.&lt;/p&gt;</description></item><item><title>Cannot connect to my SQL Management studio after moving a tempDB</title><link>https://am2.co/2019/11/01/cannot-connect-to-my-sql-management-studio-after-moving-a-tempdb/</link><pubDate>Fri, 01 Nov 2019 22:27:39 -0400</pubDate><guid>https://am2.co/2019/11/01/cannot-connect-to-my-sql-management-studio-after-moving-a-tempdb/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/252407/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In quite a bad position here. This afternoon on my tempDB I ran the query:&#10; &lt;code&gt;sp_helpfile&lt;/code&gt; to locate where my MDF and LOG file were. My MDF was on my C: drive and my LOG file was on a D: drive so I've run the following query to move this Log file from the D: drive back to C: drive. (This may not have been exactly the query I run as I don't remember what it was precisely!)&lt;/p&gt;</description></item><item><title>Is it possible to re-use a query plan from the plan cache from one database in another database?</title><link>https://am2.co/2019/11/01/is-it-possible-to-re-use-a-query-plan-from-the-plan-cache-from-one-database-in-another-database/</link><pubDate>Fri, 01 Nov 2019 18:08:43 -0400</pubDate><guid>https://am2.co/2019/11/01/is-it-possible-to-re-use-a-query-plan-from-the-plan-cache-from-one-database-in-another-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/252394/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;For example, if I hit the sys dynamic views to select a specific query plan, am I able to insert that query plan into another database's plan cache, that runs the same exact query? (I know the query is hashed and compared to determine when to generate a new plan, so in my example I would ensure the query truly is exactly the same character by character.)&lt;/p&gt;</description></item><item><title>SQL Server Page File location - where to put it?</title><link>https://am2.co/2019/10/31/sql-server-page-file/</link><pubDate>Thu, 31 Oct 2019 08:32:27 -0400</pubDate><guid>https://am2.co/2019/10/31/sql-server-page-file/</guid><description>&lt;p&gt;&lt;a href="https://serverfault.com/q/990091/299354"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;There are a lot of recommendations about the sizing of the windows page file. What I am looking for is the correct placement.&lt;/p&gt;&#10;&lt;p&gt;We are running a MS SQL server on a Server 2012R2 VM with multiple seperate virtual disks:&lt;/p&gt;</description></item><item><title>Why can't I restore encrypted backup through front end?</title><link>https://am2.co/2019/10/30/restore-encrypted-backup/</link><pubDate>Wed, 30 Oct 2019 12:41:23 -0400</pubDate><guid>https://am2.co/2019/10/30/restore-encrypted-backup/</guid><description>&lt;p&gt;&lt;a href="https://serverfault.com/q/989930/299354"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I&amp;rsquo;m just starting to experiment with encrypting backups, I think I now understand it and have got the process working, but something strange is happening with restoring.&lt;/p&gt;&#10;&lt;p&gt;On &lt;strong&gt;Server A&lt;/strong&gt; (SQL 2014 Standard) I have created a new master key and certificate and successfully produced an encrypted bak file and have also exported the key and cert files.&lt;/p&gt;</description></item><item><title>How to create date buckets in T-SQL</title><link>https://am2.co/2019/10/28/how-to-create-date-buckets-in-t-sql/</link><pubDate>Mon, 28 Oct 2019 10:00:47 -0400</pubDate><guid>https://am2.co/2019/10/28/how-to-create-date-buckets-in-t-sql/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=zYY6Q4nRTS4" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/StockSnap_MHIAORM8Q6.jpg" alt="" width="512" height="341" class="alignright size-full wp-image-2263" /&gt;&lt;/a&gt;&#10;I was fiddling around with some data, looking at making a quick aging report. I probably should have reached for &lt;a href="https://powerbi.microsoft.com/en-us/desktop/" rel="noopener noreferrer" target="_blank"&gt;Power BI Desktop&lt;/a&gt;, but sometimes I can be stubborn, and I wanted to get my T-SQL to work&amp;ndash;if nothing else to figure out how to make it work.&lt;/p&gt;</description></item><item><title>Does a Window 10 license allow using it as a Web server?</title><link>https://am2.co/2019/10/27/does-a-window-10-license-allow-using-it-as-a-web-server/</link><pubDate>Sun, 27 Oct 2019 17:50:53 -0400</pubDate><guid>https://am2.co/2019/10/27/does-a-window-10-license-allow-using-it-as-a-web-server/</guid><description>&lt;p&gt;&lt;a href="https://superuser.com/q/1496496/630094"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am looking to set up a Web server for a project.&lt;/p&gt;&#10;&lt;p&gt;The server would be using a custom application developed in VB.Net using SQL Server for data storage. The application uses 3rd party components (DLL&amp;rsquo;s) that are available for Windows only.&lt;/p&gt;</description></item><item><title>How to implement a unique key for a long VARCHAR column in MySQL</title><link>https://am2.co/2019/10/27/how-to-implement-a-unique-key-for-a-long-varchar-column-in-mysql/</link><pubDate>Sun, 27 Oct 2019 04:43:04 -0400</pubDate><guid>https://am2.co/2019/10/27/how-to-implement-a-unique-key-for-a-long-varchar-column-in-mysql/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/252009/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need to let MySQL to check the uniqueness of a VARCHAR column which is 5000 max length and is not the primary key. I can use an index of length 500 on the column to speed up query, but how to create an unique key that works? &lt;/p&gt;</description></item><item><title>convert sql-excel date to recognizable format</title><link>https://am2.co/2019/10/26/convert-sql-excel-date-to-recognizable-format/</link><pubDate>Sat, 26 Oct 2019 10:27:37 -0400</pubDate><guid>https://am2.co/2019/10/26/convert-sql-excel-date-to-recognizable-format/</guid><description>&lt;p&gt;&lt;a href="https://superuser.com/q/1496171/630094"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a large csv file(1.1G) exported from SQL Server. I would like to do data wrangling in python, but I had a few problems doing this. The original csv file dates look like this &lt;code&gt;00:07.5, 00:08.3, 00:48.7&lt;/code&gt;, I can manually convert them to &lt;code&gt;1/12/2015 12:00:07 am, 1/12/2015 12:00:08 am, 1/12/2015 12:00:49 am&lt;/code&gt; in excel by formatting the entire column to make it in &lt;code&gt;d/m/yy h:mm:ss&lt;/code&gt;, but sometimes output is weird like &lt;code&gt;100:00:00&lt;/code&gt;, or it just kept the time but not the dates, when I finally successfully did this, I noticed that the file size had shrank to &lt;code&gt;36.6 MB&lt;/code&gt; from &lt;code&gt;1.1G&lt;/code&gt;. I received the excel notification:&lt;/p&gt;</description></item><item><title>How does a database RESTORE affect plan cache?</title><link>https://am2.co/2019/10/24/how-does-a-database-restore-affect-plan-cache/</link><pubDate>Thu, 24 Oct 2019 10:12:48 -0400</pubDate><guid>https://am2.co/2019/10/24/how-does-a-database-restore-affect-plan-cache/</guid><description>&lt;p&gt;If you restore a database, what does that do to the plan cache? Well, let&amp;rsquo;s start by looking at &lt;a href="https://web.archive.org/web/20190906084812/https://docs.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-2017#general-remarks" rel="noopener noreferrer" target="_blank"&gt;the documentation for RESTORE&lt;/a&gt;. (Emphasis mine)&lt;/p&gt;&#10;&lt;blockquote&gt;&lt;strong&gt;Restoring a database clears the plan cache for the instance of SQL Server.&lt;/strong&gt; Clearing the plan cache causes a recompilation of all subsequent execution plans and can cause a sudden, temporary decrease in query performance. For each cleared cachestore in the plan cache, the SQL Server error log contains the following informational message: " SQL Server has encountered %d occurrence(s) of cachestore flush for the '%s' cachestore (part of plan cache) due to some database maintenance or reconfigure operations". This message is logged every five minutes as long as the cache is flushed within that time interval.&lt;/blockquote&gt;&#10;&lt;figure class="wp-caption alignright" style="max-width:512px"&gt;&lt;a href="https://www.youtube.com/watch?v=RuW1f6FI18g" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/joshua-naidoo-J954SeqDitQ-unsplash.jpg" alt="" width="512" height="342" class="size-large wp-image-2248" /&gt;&lt;/a&gt; This beautifully restored Mini would clear some cash from my bank account.&lt;/figure&gt;&#10;&lt;p&gt;Yikes. That first sentence sounds like it is going to clear the cache for &lt;strong&gt;the entire instance&lt;/strong&gt;. That seems excessive. If I restore a new database (ie, I am creating a new database from backup), that shouldn&amp;rsquo;t affect the plan cache at all. And if I restore over top an existing database, I would only expect the cache for that one database to be affected. I can&amp;rsquo;t think of a scenario where I would want to &amp;ldquo;clear the plan cache for the instance&amp;rdquo; when doing a restore.&lt;/p&gt;</description></item><item><title>What the heck is Accelerated Database Recovery?</title><link>https://am2.co/2019/10/21/what-the-heck-is-accelerated-database-recovery/</link><pubDate>Mon, 21 Oct 2019 10:00:15 -0400</pubDate><guid>https://am2.co/2019/10/21/what-the-heck-is-accelerated-database-recovery/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:512px"&gt;&lt;a href="https://www.youtube.com/watch?v=54I5RU-RNhQ"&gt;&lt;img src="https://am2.co/wp-content/uploads/eggy-febryano-de_A1VmNapQ-unsplash-1024x768.jpg" alt="" width="512" height="384" class="size-large wp-image-2229" /&gt;&lt;/a&gt; The intersection of Crash Recovery Boulevard and Version Store Avenue is now known as ADR Square.&lt;/figure&gt;&#10;Last week, I wrote about the &lt;a href="https://am2.co/2019/10/15/what-the-heck-is-the-sql-server-version-store/" rel="noopener noreferrer" target="_blank"&gt;SQL Server Version Store&lt;/a&gt;. The week before, I looked at &lt;a href="https://am2.co/2019/10/12/recovery-of-database-is-0-complete-approximately-1000000-seconds-remain/" rel="noopener noreferrer" target="_blank"&gt;crash recovery&lt;/a&gt;. Let's look next at a new feature in SQL Server 2019, where these two features intersect: Accelerated Database Recovery.&#10;&lt;h2 id="what-is-it"&gt;What is it?&lt;/h2&gt;&#10;&lt;p&gt;Accelerated Database Recovery(ADR) is a new feature intended to speed up the recovery process, which could be very slow, particularly when there are long-running, large transactions. ADR is not just for recovery after a crash, but also helps in other scenarios where the transaction log needs to be recovered&amp;ndash;including Availability Group secondary redo and Failover Cluster Instance failovers.&lt;/p&gt;</description></item><item><title>SQL log file 2TB is not enough, now what?</title><link>https://am2.co/2019/10/18/sql-log-file-2tb-is-not-enough-now-what/</link><pubDate>Fri, 18 Oct 2019 12:04:01 -0400</pubDate><guid>https://am2.co/2019/10/18/sql-log-file-2tb-is-not-enough-now-what/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/251455/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This is a hypothetical question, that flows from the answer &lt;a href="https://dba.stackexchange.com/a/251451/21924"&gt;by sepupic&lt;/a&gt; where they explain that 2TB is the physical limit for SQL log file.&lt;/p&gt;&#10;&lt;blockquote&gt;&#10; &lt;p&gt;if you need it more than 2Tb you add the second log file.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;I have long held the belief that multiple log files are bad as outlined in the post &lt;a href="https://dba.stackexchange.com/q/62344/21924"&gt;Multiple Transaction Log files and performance impact&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Copying SQL Server settings to new server</title><link>https://am2.co/2019/10/17/copying-sql-server-settings-to-new-server/</link><pubDate>Thu, 17 Oct 2019 13:26:20 -0400</pubDate><guid>https://am2.co/2019/10/17/copying-sql-server-settings-to-new-server/</guid><description>&lt;p&gt;&lt;a href="https://serverfault.com/q/988391/299354"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We are a small business using a single SQL Server 2014 instance as our main data platform.&lt;/p&gt;&#10;&lt;p&gt;We now need to set up a second instance (2017) to hold additional data - this is to be standalone, ie not replicated or actively linked to the main server.&lt;/p&gt;</description></item><item><title>What the heck is the SQL Server Version Store?</title><link>https://am2.co/2019/10/15/what-the-heck-is-the-sql-server-version-store/</link><pubDate>Tue, 15 Oct 2019 10:30:13 -0400</pubDate><guid>https://am2.co/2019/10/15/what-the-heck-is-the-sql-server-version-store/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:525px"&gt;&lt;a href="https://www.youtube.com/watch?v=zEEXetPS_lY" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/MicrobusVersioning-300x200.jpg" alt="" width="525" height="350" class="size-large wp-image-2222" /&gt; &lt;/a&gt; Sure, Microsoft does versioning, but check out this Microbus versioning!&lt;/figure&gt;&#10;&lt;p&gt;Maybe you&amp;rsquo;ve read about the &lt;a href="https://www.sql.kiwi/2014/05/read-committed-snapshot-isolation/" rel="noopener noreferrer" target="_blank"&gt;Read Committed Snapshot&lt;/a&gt; (RCSI) or &lt;a href="https://www.sql.kiwi/2014/06/the-snapshot-isolation-level/" rel="noopener noreferrer" target="_blank"&gt;Snapshot&lt;/a&gt; Isolation levels. Or maybe you were trying to figure out &lt;a href="https://littlekendra.com/2016/02/18/how-to-choose-rcsi-snapshot-isolation-levels/" rel="noopener noreferrer" target="_blank"&gt;the difference between the two snapshot isolation levels&lt;/a&gt;. Perhaps you&amp;rsquo;ve looked into &lt;a href="https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/active-secondaries-readable-secondary-replicas-always-on-availability-groups" rel="noopener noreferrer" target="_blank"&gt;read-only secondary replicas in your Availability Group&lt;/a&gt;, or even &lt;a href="https://dba.stackexchange.com/questions/237671/long-running-query-on-read-only-replica-that-takes-moments-on-the-primary" rel="noopener noreferrer" target="_blank"&gt;had some problems with AG secondaries&lt;/a&gt;. Along the way, people and articles have mentioned this &amp;ldquo;version store&amp;rdquo; thing.&lt;/p&gt;</description></item><item><title>Recovery of database is 0% complete (approximately 1000000 seconds remain)</title><link>https://am2.co/2019/10/12/recovery-of-database-is-0-complete-approximately-1000000-seconds-remain/</link><pubDate>Sat, 12 Oct 2019 10:52:29 -0400</pubDate><guid>https://am2.co/2019/10/12/recovery-of-database-is-0-complete-approximately-1000000-seconds-remain/</guid><description>&lt;div&gt;&lt;figure class="wp-caption alignright" style="max-width:450px"&gt;&lt;a href="https://www.youtube.com/watch?v=eTeg1txDv8w" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/simon-english-NvSGP844aA4-unsplash.jpg" alt="" width="450" height="300" class="size-medium wp-image-2217" /&gt;&lt;/a&gt; recovering from this crash is going to be pretty difficult&lt;/figure&gt;&lt;/div&gt;&#10;If you've ever had a server reboot unexpectedly, you've probably seen SQL Server start up, with some databases "stuck" in recovery status, then eventually they come online. Or maybe you thought "this session is stuck in rollback. It'll be quicker if I just reboot the server than wait for it to roll back!" ...only to find out that after restart, the database went into recovery, and you were left waiting impatiently for the database to come online.&#10;&lt;p&gt;In both of these scenarios, the database is going through the &amp;ldquo;crash recovery&amp;rdquo; status.&lt;/p&gt;</description></item><item><title>SQL database stuck in recovery</title><link>https://am2.co/2019/10/12/sql-database-stuck-in-recovery/</link><pubDate>Sat, 12 Oct 2019 00:11:33 -0400</pubDate><guid>https://am2.co/2019/10/12/sql-database-stuck-in-recovery/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/250903/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have SQL server 2017. I have one 3 TB size database there. Somehow due to long running transaction the database got stuck 'IN Recovery' mode after SQL server Restarted. When I checked the sql error logs it says 2 189 255 seconds remaining (Phase 2 of 3) completed which is almost 25 days. My goal is to bring the database online even if I lose some data.&lt;/p&gt;</description></item><item><title>How To Fix High DTU Usage on Specific Query</title><link>https://am2.co/2019/10/10/how-to-fix-high-dtu-usage-on-specific-query/</link><pubDate>Thu, 10 Oct 2019 18:03:01 -0400</pubDate><guid>https://am2.co/2019/10/10/how-to-fix-high-dtu-usage-on-specific-query/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/250789/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a query that runs every few seconds on a Microsoft SQL Azure Database. It is from a web job that checks if there are actions that need to be done based on rows in a specific table (its a queueing table). Based on the image attached, does anyone have any suggestion of how i could reduce the DTU usage for the query in question, it is causing the database to reach 100% CPU. &lt;/p&gt;</description></item><item><title>Linked server from SQL server on AWS RDS to On premises MS SQL server database</title><link>https://am2.co/2019/10/07/linked-server-from-sql-server-on-aws-rds-to-on-premises-ms-sql-server-database/</link><pubDate>Mon, 07 Oct 2019 07:17:18 -0400</pubDate><guid>https://am2.co/2019/10/07/linked-server-from-sql-server-on-aws-rds-to-on-premises-ms-sql-server-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/250409/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We are planing to migrate an on-premises SQL Server db to AWS RDS SQL Server. My only concern is how can I create a linked server from AWS RDS SQL Server to on-premises SQL Server db? Is it possible? I am checking it because there are many views using linked server to other on-premises dbs.&lt;/p&gt;</description></item><item><title>Monetary value in integer over decimal datatype</title><link>https://am2.co/2019/09/15/monetary-value-in-integer-over-decimal-datatype/</link><pubDate>Sun, 15 Sep 2019 09:08:25 -0400</pubDate><guid>https://am2.co/2019/09/15/monetary-value-in-integer-over-decimal-datatype/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/248815/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have came across several articles that mentioned that advise on not to store monetary value as decimal, but use integer instead.&#10;The reasoning that it does not store actual value and will cause some rounding difference/errors.&#10;But i have yet ever participate in any project that use an integer datatype for monetary value in database storage.&lt;/p&gt;</description></item><item><title>When to put a non-clustered index on your clustering key</title><link>https://am2.co/2019/09/03/when-to-put-a-non-clustered-index-on-your-clustering-key/</link><pubDate>Tue, 03 Sep 2019 21:17:14 -0400</pubDate><guid>https://am2.co/2019/09/03/when-to-put-a-non-clustered-index-on-your-clustering-key/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="https://www.youtube.com/watch?v=uvWL6_A7uQc" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/david-kohler-vIi2aNfPQ00-unsplash.jpg" alt="" width="400" height="600" class="size-medium wp-image-2121" /&gt;&lt;/a&gt; These vines are clustered by Cabernet Sauvignon.&lt;/figure&gt;&#10;#### First off, let's remember the difference between clustered &amp; nonclustered indexes&#10;&lt;p&gt;The &lt;strong&gt;clustered index&lt;/strong&gt; is organized by the key columns. It also includes every other column as part of the row structure (ie, it has the entire row).&lt;/p&gt;</description></item><item><title>Why does ALTER let me DROP?</title><link>https://am2.co/2019/08/28/why-does-alter-let-me-drop/</link><pubDate>Wed, 28 Aug 2019 09:00:19 -0400</pubDate><guid>https://am2.co/2019/08/28/why-does-alter-let-me-drop/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=m3f0aW_-6gc" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/chuttersnap-cGXdjyP6-NU-unsplash.jpg" alt="" width="400" height="267" class="alignright size-medium wp-image-2102" /&gt;&lt;/a&gt;&#10;I was recently chatting with a coworker, discussing why there is no discrete &lt;code&gt;DROP&lt;/code&gt; permission for tables, procedures, etc. The conversation actually came from a &lt;a href="https://sqlcommunity.slack.com/messages/C1MS1RA4B" rel="noopener noreferrer" target="_blank"&gt;#SQLHelp&lt;/a&gt; question on &lt;a href="http://sqlslack.com" rel="noopener noreferrer" target="_blank"&gt;SQL Slack&lt;/a&gt; that was asked along the lines of &amp;ldquo;What if I want to let a user &lt;code&gt;CREATE&lt;/code&gt; and &lt;code&gt;ALTER&lt;/code&gt; objects, but not &lt;code&gt;DROP&lt;/code&gt; them?&amp;rdquo;&lt;/p&gt;</description></item><item><title>Year 4: May 2017 - May 2018</title><link>https://am2.co/2019/05/21/year-4-2017-2018/</link><pubDate>Tue, 21 May 2019 08:30:21 -0400</pubDate><guid>https://am2.co/2019/05/21/year-4-2017-2018/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=RUaEDuxAVhY" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/david-pisnoy-562428-unsplash-300x225.jpg" alt="" width="300" height="225" class="alignright size-medium wp-image-1876" /&gt;&lt;/a&gt;&#10;In &lt;a href="https://am2.co/2019/05/20/year-3-2016-2017/" rel="noopener noreferrer" target="_blank"&gt;Year Three&lt;/a&gt;, I had a pretty big year. I kind of felt like I had peaked. I had received the &lt;a href="https://blogs.sentryone.com/aaronbertrand/2016-community-influencer/" rel="noopener noreferrer" target="_blank"&gt;Community Influencer of the Year Award&lt;/a&gt; and &lt;a href="2017/03/congratulations-2017-microsoft-mvp/" rel="noopener noreferrer" target="_blank"&gt;Microsoft MVP Award&lt;/a&gt;. Where do you go from there? Mostly, I just wanted to keep up what I was doing, and keep sharing what I was doing.&lt;/p&gt;</description></item><item><title>#LGBT channel on SQL Slack!</title><link>https://am2.co/2019/05/14/lgbt-sql-slack/</link><pubDate>Tue, 14 May 2019 09:00:34 -0400</pubDate><guid>https://am2.co/2019/05/14/lgbt-sql-slack/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Q9wdMJmuBlA" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/LGBTLegoHeart-300x225.jpg" alt="" width="400" height="300" class="alignright size-medium wp-image-1870" /&gt;&lt;/a&gt;&#10;Last night while having dinner with my husband, I had a thought and messaged Chrissy LeMaire (&lt;a href="https://blog.netnerds.net" rel="noopener noreferrer" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/cl" rel="noopener noreferrer" target="_blank"&gt;twitter&lt;/a&gt;) on the &lt;a href="http://sqlslack.com" rel="noopener noreferrer" target="_blank"&gt;SQL Server Community Slack&lt;/a&gt;.&lt;/p&gt;&#10;&lt;blockquote&gt;Thoughts on an LGBTQ channel here? I doubt it would be very active... But I'd love to have a spot for the data queers to find each other. Especially if anyone ever has a gay in the workplace question or whatever.&lt;/blockquote&gt;&#10;&lt;p&gt;It was super duper late at night in Chrissy&amp;rsquo;s timezone, but I sent the message so I wouldn&amp;rsquo;t forget. Chrissy is one of the admins on the SQL Slack workspace, and fellow member of Team Gay, so I was really looking for validation that it was a good idea, and help getting it created.&lt;/p&gt;</description></item><item><title>What the heck is downtime, anyway?</title><link>https://am2.co/2019/04/15/what-the-heck-is-downtime-anyway/</link><pubDate>Mon, 15 Apr 2019 09:00:17 -0400</pubDate><guid>https://am2.co/2019/04/15/what-the-heck-is-downtime-anyway/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:288px"&gt;&lt;a href="https://www.youtube.com/watch?v=XVggK-IpOvA" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/elijah-o-donnell-603766-unsplash-576x1024.jpg" alt="" width="288" height="512" class="size-large wp-image-1756" /&gt;&lt;/a&gt; If a server falls in a data center and no users are around to notice, does it count as downtime?&lt;/figure&gt;&#10;There's a lot of discussion about preventing downtime. As a DBA and IT professional, it's my sworn duty to prevent downtime. I usually describe my job as DBA something along the lines of, "to make sure data is always available to the people and applications that need it, and never available to the people and applications that shouldn't have it." Preventing downtime is certainly important for that first part--but how the heck do you define downtime?&#10;&lt;h2 id="what-downtime-means-to-most-dbas"&gt;What &amp;ldquo;downtime&amp;rdquo; means to most DBAs&lt;/h2&gt;&#10;&lt;p&gt;When DBAs think about downtime, we often think in terms of &amp;ldquo;the server is offline&amp;rdquo; or &amp;ldquo;the database isn&amp;rsquo;t responding to queries&amp;rdquo; or even &amp;ldquo;the database isn&amp;rsquo;t responding to queries &lt;em&gt;fast enough&lt;/em&gt;.&amp;rdquo; But is that really downtime?&lt;/p&gt;</description></item><item><title>Configuring the distribution database in an Availability Group</title><link>https://am2.co/2019/04/08/configuring-the-distribution-database-in-an-availability-group/</link><pubDate>Mon, 08 Apr 2019 08:00:23 -0400</pubDate><guid>https://am2.co/2019/04/08/configuring-the-distribution-database-in-an-availability-group/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:600px"&gt;&lt;a href="https://www.youtube.com/watch?v=5qSrmeiWsuc" rel="noopener noreferrer" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/Replication.jpg" alt="" width="600" height="488" class="size-medium wp-image-1749" /&gt;&lt;/a&gt; I 💜 Replication&lt;/figure&gt;&#10;&lt;p&gt;Starting with SQL Server 2017 CU6 and SQL Server 2016 SP2-CU3, you can now configure your distribution database as part of an Availability Group (AG). Up until now, your distribution database could only be part of a standalone instance, or failover cluster instance (FCI). In this first round, there&amp;rsquo;s a pretty big &lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/replication/configure-distribution-availability-group" rel="noopener noreferrer" target="_blank"&gt;list of limitations &amp;amp; restrictions&lt;/a&gt;. In fact, you&amp;rsquo;ll notice that the &amp;ldquo;supported scenarios&amp;rdquo; list is shorter than the &amp;ldquo;limitations or exclusions.&amp;rdquo;&lt;/p&gt;</description></item><item><title>Code to purge data based on creation date</title><link>https://am2.co/2019/04/04/code-to-purge-data-on-creation-date/</link><pubDate>Thu, 04 Apr 2019 08:30:16 -0400</pubDate><guid>https://am2.co/2019/04/04/code-to-purge-data-on-creation-date/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:678px"&gt;&lt;a href="https://www.youtube.com/watch?v=nHlJODYBLKs"&gt;&lt;img src="https://am2.co/wp-content/uploads/MarieKondoData-678x381.png" alt="" width="678" height="381" class="size-mh-magazine-lite-content wp-image-1743" /&gt;&lt;/a&gt; Only one thing can spark more joy than cleaning up old data. Doggos. &lt;/figure&gt;&#10;Yesterday, &lt;a href="https://am2.co/2019/04/03/purging-data-with-batched-deletes/"&gt;I talked about batching deletes&lt;/a&gt;, and the day before I talked about &lt;a href="https://am2.co/2019/04/02/the-thrill-of-purging-old-data/"&gt;how much I like to delete data&lt;/a&gt;, and why it's necessary to do it, despite being a data packrat.&#10;&lt;p&gt;Today, let&amp;rsquo;s look at just one scenario, and how I like to handle it. In my experience, this is one of the most common purge requirements (and probably the easiest), so first, let&amp;rsquo;s look at the business requirements.&lt;/p&gt;</description></item><item><title>Purging data with batched deletes</title><link>https://am2.co/2019/04/03/purging-data-with-batched-deletes/</link><pubDate>Wed, 03 Apr 2019 08:30:13 -0400</pubDate><guid>https://am2.co/2019/04/03/purging-data-with-batched-deletes/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:678px"&gt;&lt;a href="https://www.youtube.com/watch?v=4VO1nYGHw0c" target="_blank" rel="noopener noreferrer"&gt;&lt;img src="https://am2.co/wp-content/uploads/pawel-czerwinski-759725-unsplash-678x381.jpg" alt="" width="678" height="381" class="size-mh-magazine-lite-content wp-image-1739" /&gt;&lt;/a&gt; This person understands that batching deletes can be helpful.&lt;/figure&gt;&#10;Yesterday, I wrote about &lt;a href="https://am2.co/2019/04/02/the-thrill-of-purging-old-data/"&gt;the importance of planning your data purges&lt;/a&gt;. Today, let's look at the simplest requirement for purging data: Keep data for X days after it's created. There are &lt;strong&gt;tons&lt;/strong&gt; of cases where this is the rule. Log data, telemetry data, even transactional data is often retained based on X days since it is created.&#10;&lt;p&gt;Given how common this scenario is, let&amp;rsquo;s talk in a bit more detail about I like to go about deleting it. Deleting data is easy, right? &lt;code&gt; DELETE t FROM dbo.Transactions AS t WHERE CreateDate &amp;lt;= DATEADD(dd,-90,GETDATE());&lt;/code&gt;&lt;/p&gt;</description></item><item><title>The thrill of purging old data</title><link>https://am2.co/2019/04/02/the-thrill-of-purging-old-data/</link><pubDate>Tue, 02 Apr 2019 09:00:54 -0400</pubDate><guid>https://am2.co/2019/04/02/the-thrill-of-purging-old-data/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:678px"&gt;&lt;a href="https://www.youtube.com/watch?v=wdGARtyNaQQ" target="_blank" rel="noopener noreferrer"&gt;&lt;img src="https://am2.co/wp-content/uploads/priscilla-du-preez-101759-unsplash-678x381.jpg" alt="" width="678" height="381" class="size-mh-magazine-lite-content wp-image-1737" /&gt;&lt;/a&gt; I get a thrill from roller coasters, but for some people it just makes them purge their lunch.&lt;/figure&gt;&#10;&lt;p&gt;DBAs &amp;amp; Data professionals tend to be digital pack rats. My personal Google Drive is filled with random files that I refused to part with&amp;ndash;even though it&amp;rsquo;s of questionable value. I lament that I do not have a copy of every paper I typed in high school or college&amp;ndash;and I envy those who do. You never know when you&amp;rsquo;ll need notes from that meeting 6 years ago, or when you&amp;rsquo;ll need that funny GIF you created for an inside joke you no longer remember.&lt;/p&gt;</description></item><item><title>How to pause the subscriber end of transactional replication</title><link>https://am2.co/2019/02/12/how-to-pause-the-subscriber-end-of-transactional-replication/</link><pubDate>Tue, 12 Feb 2019 08:10:04 -0500</pubDate><guid>https://am2.co/2019/02/12/how-to-pause-the-subscriber-end-of-transactional-replication/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/229484/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;How do I go about pausing transactional replication on the subscriber end.&lt;/p&gt;&#10;&lt;p&gt;We have a publisher on Server A, a distributor on Server B and a subscriber on Server C. All are in the same network.&lt;/p&gt;&#10;&lt;p&gt;Some background, we have quite a busy BizTalk server where we replicate the data from the BAM parts to a separate database server which will be used for a customized web application for statistics, searching etc. Seeing as the tables in the BizTalk server are both quite large and missing indexes etc since they're basically just there to have data dumped into them we opted to have the second, replicated database in which we can apply various optimizations for reading the data.&lt;/p&gt;</description></item><item><title>SQL: A love story</title><link>https://am2.co/2019/01/21/sql-love-story/</link><pubDate>Mon, 21 Jan 2019 08:00:54 -0500</pubDate><guid>https://am2.co/2019/01/21/sql-love-story/</guid><description>&lt;p&gt;I&amp;rsquo;m a college drop-out. When I was trying to figure out my life, a friend (my brother&amp;rsquo;s ex) referred me to a software company where she was working&amp;ndash;I got the job because I was (a) breathing, (b) eager to do the job, and (c) cheap. The application we built and sold was built with VB6, SQL Server, and later a bit of VB.NET. In my one year of college, I&amp;rsquo;d decided that I hate software development, but I fell in love with SQL Server. I&amp;rsquo;ve spent most of my career working with SQL Server (albeit a brief stint doing Oracle stuff), and I&amp;rsquo;m very happy that I fell in love with the SQL language and SQL Server in particular.&lt;/p&gt;</description></item><item><title>Managed Instance Restart</title><link>https://am2.co/2019/01/05/managed-instance-restart/</link><pubDate>Sat, 05 Jan 2019 02:07:58 -0500</pubDate><guid>https://am2.co/2019/01/05/managed-instance-restart/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/226393/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Does anyone know how to restart a SQL Server Managed Instance?&lt;/p&gt;&#10;&lt;p&gt;The stop / start / reset are all grayed out, so that’s really. It an option.&lt;/p&gt;&#10;&lt;p&gt;Any thoughts?&lt;/p&gt;&#10;&lt;p&gt;Thanks...&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/226393/52344" rel="noopener" target="_blank"&gt;2019-01-05&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/169407" rel="noopener" target="_blank"&gt;Kevin Wilkie&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;p&gt;You don't restart Managed Instance. The beauty of PaaS is that the cloud service provider ensures that you get a certain uptime SLA-- 99.99% in this case. &lt;/p&gt;</description></item><item><title>How to analyze compression options for Azure SQL Database?</title><link>https://am2.co/2019/01/04/how-to-analyze-compression-options-for-azure-sql-database/</link><pubDate>Fri, 04 Jan 2019 19:52:41 -0500</pubDate><guid>https://am2.co/2019/01/04/how-to-analyze-compression-options-for-azure-sql-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/226369/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;What is the most efficient way to determine whether row or page or columnstore compression (or none) would be most effective for each index in an Azure SQL Database (standard or premium tier) used for OLTP, where &lt;strong&gt;sp_estimate_data_compression_savings&lt;/strong&gt; is not supported?&lt;/p&gt;</description></item><item><title>Installation of SQL Server Express LocalDB 2017</title><link>https://am2.co/2018/11/04/installation-of-sql-server-express-localdb-2017/</link><pubDate>Sun, 04 Nov 2018 14:14:51 -0500</pubDate><guid>https://am2.co/2018/11/04/installation-of-sql-server-express-localdb-2017/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/221745/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I want to install Microsoft SQL Server LocalDB 2017 on my system. I downloaded SQL Server Express Setup (about 5.1 MB). Then I opened it and chose 'Download Media' option and then chose LocalDB. Then it downloaded SqlLocalDB.msi setup (about 45.9 MB). I ran the setup and installed it on my computer. I don't know what to do next. Can someone help me, please?&lt;/p&gt;</description></item><item><title>how azure sql geo replication works internally?</title><link>https://am2.co/2018/11/02/how-azure-sql-geo-replication-works-internally/</link><pubDate>Fri, 02 Nov 2018 10:22:13 -0400</pubDate><guid>https://am2.co/2018/11/02/how-azure-sql-geo-replication-works-internally/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/221625/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;My company moved to azure and started to use azure Sql database and geo replication.&lt;/p&gt;&#10;&lt;p&gt;For our on-premise servers, we heavily rely on Microsoft transactional replication to move data. Now we setup transactional replication between on-premise server (publisher) and azure sql db. Then we found that the transactional replication itself is constantly consuming 100% DTU on azure(we are using a 125 DTU P1).&lt;/p&gt;</description></item><item><title>SQL Visual Studio Find and Replace in Publish Profile</title><link>https://am2.co/2018/10/29/sql-visual-studio-find-and-replace-in-publish-profile/</link><pubDate>Mon, 29 Oct 2018 20:48:28 -0400</pubDate><guid>https://am2.co/2018/10/29/sql-visual-studio-find-and-replace-in-publish-profile/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/221293/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have source control in Visual Studio Database Projects (SSDT). To make cross database references, we utilize something like this below in Project References.&lt;/p&gt;&#10;&lt;p&gt;We need Project references, since Otherdatabase, can choose between two options at our company. Most of the time, its 90% Database A, and 10% Database B.&lt;/p&gt;</description></item><item><title>How can I permanently remove replication by script if I only have access to the subscriber?</title><link>https://am2.co/2018/10/23/how-can-i-permanently-remove-replication-by-script-if-i-only-have-access-to-the-subscriber/</link><pubDate>Tue, 23 Oct 2018 23:10:17 -0400</pubDate><guid>https://am2.co/2018/10/23/how-can-i-permanently-remove-replication-by-script-if-i-only-have-access-to-the-subscriber/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/220528/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We've been building a replication network of DBs to give us some degree of Always On without paying the full price tag. Currently we have a publisher DB which replicates to a handful of subscribers, so that if the publisher goes down, we can promote a subscriber to be the new publisher. As is, this is a tedious manual process, but we want to start scripting elements of it so that the process is quicker and closer to being automated.&lt;/p&gt;</description></item><item><title>Can't overwrite an existing Azure SQL Managed Instance database during restore</title><link>https://am2.co/2018/10/12/cant-overwrite-an-existing-azure-sql-managed-instance-database-during-restore/</link><pubDate>Fri, 12 Oct 2018 01:07:27 -0400</pubDate><guid>https://am2.co/2018/10/12/cant-overwrite-an-existing-azure-sql-managed-instance-database-during-restore/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/219916/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We're working on migrating some SQL Server VMs to Azure SQL Managed Instances. We did an initial backup/restore without a problem:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;RESTORE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DATABASE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;xxx&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;https://&amp;lt;account-name&amp;gt;.blob.core.windows.net/&amp;lt;container-name&amp;gt;/&amp;lt;filename&amp;gt;.bak&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After doing testing, we now need to do a fresh restore from our SQL VMs. We started doing the same process we initially did but when restoring, we got an error:&lt;/p&gt;</description></item><item><title>Under what conditions could restore of a huge database get delayed, in SQL server 2016, hosted on VM?</title><link>https://am2.co/2018/10/05/under-what-conditions-could-restore-of-a-huge-database-get-delayed-in-sql-server-2016-hosted-on-vm/</link><pubDate>Fri, 05 Oct 2018 11:14:09 -0400</pubDate><guid>https://am2.co/2018/10/05/under-what-conditions-could-restore-of-a-huge-database-get-delayed-in-sql-server-2016-hosted-on-vm/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/219348/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have system where my database gets restored every night, and off late the restore is taking a lot longer from past few days. &lt;/p&gt;&#10;&lt;p&gt;Here is server config:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;ES 2637 XEON @ 3.5 Ghz&lt;/li&gt;&#10;&lt;li&gt;Windows virtual server 2012 R2 hosted in a Hyper V environment&lt;/li&gt;&#10;&lt;li&gt;RAM: 128 GB&lt;/li&gt;&#10;&lt;li&gt;8 CPUs&lt;/li&gt;&#10;&lt;li&gt;Ethernet: 500 Kps Throughput &lt;/li&gt;&#10;&lt;li&gt;Virtual Memory&#10;&lt;ul&gt;&#10;&lt;li&gt;Max Size:132,096 MB&lt;/li&gt;&#10;&lt;li&gt;Available: 39,395 MB&lt;/li&gt;&#10;&lt;li&gt;In Use: 92,701 MB&lt;/li&gt;&#10;&lt;/ul&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Version:&lt;/p&gt;</description></item><item><title>How Large Table before Using Clustered Columnstore Index</title><link>https://am2.co/2018/09/27/how-large-table-before-using-clustered-columnstore-index/</link><pubDate>Thu, 27 Sep 2018 16:43:03 -0400</pubDate><guid>https://am2.co/2018/09/27/how-large-table-before-using-clustered-columnstore-index/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/218751/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;At what size should we consider applying Columnstore Index on a table? Is there a SQL Server storage or design guidance? &lt;/p&gt;&#10;&lt;p&gt;Our Data Warehouse is 5TB total. Additionally, we have tables which are 100GB to 1TB which compose the database. Just curious if SQL Server has guidance on how large should table before a columnstore index is applied? &lt;/p&gt;</description></item><item><title>How do you SUM a column without having its name?</title><link>https://am2.co/2018/09/22/how-do-you-sum-a-column-without-having-its-name/</link><pubDate>Sat, 22 Sep 2018 10:54:20 -0400</pubDate><guid>https://am2.co/2018/09/22/how-do-you-sum-a-column-without-having-its-name/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/218315/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm stuck in a way that how to do sum on a column let's say first column of a table (result from another query) without knowing the column name with something like column position id.&lt;/p&gt;&#10;&lt;p&gt;it's something like this&lt;/p&gt;</description></item><item><title>Webinar: Azure SQL DB Managed Instance--A New Path to the Cloud</title><link>https://am2.co/2018/09/20/webinar-azure-sql-db-managed-instance-a-new-path-to-the-cloud/</link><pubDate>Thu, 20 Sep 2018 10:00:44 -0400</pubDate><guid>https://am2.co/2018/09/20/webinar-azure-sql-db-managed-instance-a-new-path-to-the-cloud/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=W8feSZXm2Ec" rel="noopener" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/SentryOneWebinar-Cropped.png" alt="" width="400" height="155" class="alignright size-medium wp-image-1636" /&gt;&lt;/a&gt;&#10;On October 2, 2018 at 11PM EDT, I&amp;rsquo;ll be joined by John Q. Martin (&lt;a href="https://blogs.sentryone.com/author/johnmartin/" rel="noopener" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/SQLDiplomat" rel="noopener" target="_blank"&gt;twitter&lt;/a&gt;) for a webinar on Azure SQL Database Managed Instance.&lt;/p&gt;&#10;&lt;p&gt;&lt;del datetime="2019-10-03T15:16:06+00:00"&gt;To sign up, register &lt;a href="https://info.sentryone.com/azure-sql-db-managed-instance-new-path-to-the-cloud" rel="noopener" target="_blank"&gt;here&lt;/a&gt;.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;You can access the recording of the session &lt;a href="https://info.sentryone.com/azure-sql-db-managed-instance-new-path-to-the-cloud" rel="noopener" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Follow-up Q &amp;amp; A from the live session can be found &lt;a href="https://blogs.sentryone.com/johnmartin/managed-instance-webinar-qa/" rel="noopener" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Webinar: Push Your App to Enterprise Scale with Advanced SQL Server Features</title><link>https://am2.co/2018/08/20/webinar-push-your-app-to-enterprise-scale-with-advanced-sql-server-features/</link><pubDate>Mon, 20 Aug 2018 10:00:04 -0400</pubDate><guid>https://am2.co/2018/08/20/webinar-push-your-app-to-enterprise-scale-with-advanced-sql-server-features/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=EyGuBM1ELf4"&gt;&lt;img src="https://am2.co/wp-content/uploads/SentryOneWebinar-Cropped.png" alt="" width="400" height="155" class="alignright size-medium wp-image-1636" /&gt;&lt;/a&gt;&#10;On August 28, 2018 at 2PM EDT, I&amp;rsquo;ll be joining Melissa Connors (&lt;a href="http://blogs.sqlsentry.com/author/melissaconnors/" rel="noopener" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="http://twitter.com/MelikaNoKaOi" rel="noopener" target="_blank"&gt;twitter&lt;/a&gt;), Kevin Kline (&lt;a href="http://kevinekline.com/" rel="noopener" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/kekline" rel="noopener" target="_blank"&gt;twitter&lt;/a&gt;), and Rob Sewell (&lt;a href="https://sqldbawithabeard.com/" rel="noopener" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/sqldbawithbeard" rel="noopener" target="_blank"&gt;twitter&lt;/a&gt;) for a webinar on advanced SQL Server features. The webinar centers around a real-life case study of technology SentryOne is using in it&amp;rsquo;s own database. I&amp;rsquo;ll be giving an overview of each of the features, and Melissa will cover how those features helped SentryOne boost performance. Kevin &amp;amp; Rob will be moderating&lt;/p&gt;</description></item><item><title>Performance Myths: The query result cache</title><link>https://am2.co/2018/07/23/performance-myths-the-query-result-cache/</link><pubDate>Mon, 23 Jul 2018 10:48:11 -0400</pubDate><guid>https://am2.co/2018/07/23/performance-myths-the-query-result-cache/</guid><description>&lt;img src="https://am2.co/wp-content/uploads/Myths-am-qrc-feat.png" alt="" width="850" height="130" class="alignnone size-full wp-image-2911" /&gt;&#10;&lt;p&gt;I was recently doing a training session when a developer commented that it was OK to run an expensive query twice because on the second execution, SQL Server would use the &amp;ldquo;results cache&amp;rdquo; and be &amp;ldquo;practically free&amp;rdquo;. It&amp;rsquo;s not the first time I&amp;rsquo;ve heard someone refer to a &amp;ldquo;results cache&amp;rdquo; in SQL Server. This is one of those myths that is almost true, which makes it that much more believable. If you don&amp;rsquo;t know better, you might think SQL Server has a &amp;ldquo;results cache&amp;rdquo; because the second execution of a query is often faster.&lt;/p&gt;</description></item><item><title>SQLSaturday Louisville &amp; Columbus: Let's Chat</title><link>https://am2.co/2018/07/19/sqlsaturday-louisville-columbus-lets-chat/</link><pubDate>Thu, 19 Jul 2018 15:51:21 -0400</pubDate><guid>https://am2.co/2018/07/19/sqlsaturday-louisville-columbus-lets-chat/</guid><description>&lt;p&gt;Last week, I &lt;a href="https://am2.co/2018/07/09/hanging-up-my-dba-cleats/"&gt;broke the news&lt;/a&gt; that I am joining the team at SentryOne as a Product Manager. Over the next two weekends, I&amp;rsquo;ll be speaking at two different SQLSaturday events: Louisville and Columbus. These will be my first two community events after joining the SentryOne team, and I have a big favor to ask. If you&amp;rsquo;ll be at either event, I want to talk to you — and not just at my sessions. I want to have some one-on-one conversations with users.&lt;/p&gt;</description></item><item><title>TSQL Tuesday #104: dbo.Check_FileSize</title><link>https://am2.co/2018/07/09/tsql-tuesday-104/</link><pubDate>Mon, 09 Jul 2018 23:18:12 -0400</pubDate><guid>https://am2.co/2018/07/09/tsql-tuesday-104/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=D04uazu547A"&gt;&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" alt="TSQL2SDAY" width="300" height="300" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;blockquote&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener noreferrer"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Bert Wagner&lt;/strong&gt; (&lt;a href="https:/bertwagner.com/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt; | &lt;a href="http://youtube.com/bertwagner" target="_blank" rel="noopener noreferrer"&gt;vlog&lt;/a&gt;| &lt;a href="https://twitter.com/bertwagner" target="_blank" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;). The topic: &lt;strong&gt;&lt;a href="https://bertwagner.com/2018/07/03/code-youd-hate-to-live-without-t-sql-tuesday-104-invitation/" target="_blank" rel="noopener noreferrer"&gt;Code You Would Hate To Live Without &lt;/a&gt;&lt;/strong&gt;&lt;/blockquote&gt;&#10;&lt;p&gt;It&amp;rsquo;s been a little bit since the last T-SQL Tuesday I joined, when I blogged about religion &amp;amp; politics (aka, &lt;a href="https://am2.co/2018/02/13/tsql-tuesday-99-tabs-vs-spaces/"&gt;Tabs vs Spaces&lt;/a&gt;). When I saw Bert&amp;rsquo;s excellent topic this month, I decided I&amp;rsquo;d try to get back on the horse again and do join the blog party again this month.&lt;/p&gt;</description></item><item><title>Deadlock when creating a database - A Query Store bug</title><link>https://am2.co/2018/03/20/deadlock-query-store-bug/</link><pubDate>Tue, 20 Mar 2018 09:00:17 -0400</pubDate><guid>https://am2.co/2018/03/20/deadlock-query-store-bug/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=4n5sBh5hozU" rel="noopener" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/QueryStore-300x225.jpg" alt="" width="300" height="225" class="alignright size-medium wp-image-1363" /&gt;&lt;/a&gt;&#10;Earlier tonight, I sat down to install &lt;a href="https://docs.microsoft.com/en-us/sql/reporting-services/create-deploy-and-manage-mobile-and-paginated-reports" rel="noopener" target="_blank"&gt;Reporting Services&lt;/a&gt; on my laptop. I haven&amp;rsquo;t played with SSRS 2017 yet, so I figured I&amp;rsquo;d poke around some. Much to my surprise, the configuration failed when creating the ReportServer database, reporting a deadlock. When I looked at the database instance, I found the ReportServer database there, but with no objects it in, and the ReportServerTempDB database missing.&lt;/p&gt;</description></item><item><title>Configuring Replication with Availability Groups</title><link>https://am2.co/2018/02/23/replication-availability-groups-2/</link><pubDate>Fri, 23 Feb 2018 10:00:41 -0500</pubDate><guid>https://am2.co/2018/02/23/replication-availability-groups-2/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:500px"&gt;&lt;a href="https://www.youtube.com/watch?v=_HONxwhwmgU&amp;amp;feature=youtu.be&amp;amp;t=3m3s" target="_blank" rel="noopener noreferrer"&gt;&lt;img class="wp-image-1347" src="https://am2.co/wp-content/uploads/clones-300x171.jpg" alt="" width="500" height="284" /&gt;&lt;/a&gt; I fancy myself more of a Jedi, but I appreciate the Empire's dedication to replication&lt;/figure&gt;&#10;&lt;p&gt;I&amp;rsquo;ve used replication and Availability Groups together before. Replication works great with an AG as both a publisher or a subscriber (though, not as a distributor&amp;ndash;you can&amp;rsquo;t add the distribution database to an AG).  I was surprised when I recently ran into a problem configuring replication on a database that was in an AG.&lt;/p&gt;</description></item><item><title>TSQL Tuesday #99: Tabs vs Spaces</title><link>https://am2.co/2018/02/13/tsql-tuesday-99-tabs-vs-spaces/</link><pubDate>Tue, 13 Feb 2018 07:02:30 -0500</pubDate><guid>https://am2.co/2018/02/13/tsql-tuesday-99-tabs-vs-spaces/</guid><description>&lt;p&gt;&lt;a href="https://sqlblog.org/2018/02/06/t-sql-tuesday-99"&gt;&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" alt="TSQL2SDAY" width="300" height="300" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;blockquote&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Aaron Bertrand&lt;/strong&gt; (&lt;a href="https://sqlblog.org/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt; | &lt;a href="https://twitter.com/aaronbertrand" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). The topic: &lt;strong&gt;&lt;a href="https://sqlblog.org/2018/02/06/t-sql-tuesday-99" target="_blank" rel="noopener"&gt;Dealer's Choice (Door Number 2: Bad Habits) &lt;/a&gt;&lt;/strong&gt;&lt;/blockquote&gt;&#10;&lt;p&gt;When I was a kid, &lt;a href="http://amzn.to/2GaEWjH" target="_blank" rel="noopener"&gt;Choose Your Own Adventure books&lt;/a&gt; were overwhelming because I wanted to explore every possible option&amp;ndash;some things never change. This month for T-SQL Tuesday, Aaron offers two blogging options and I&amp;rsquo;ve chosen to do both. &amp;ldquo;Door Number 1&amp;rdquo; is a challenge to write about what you do in your free time, inspired by &lt;a href="http://port1433.com/2017/12/13/keeping-sqlibirum-looking-back-on-what-mattered-most-this-year/" target="_blank" rel="noopener"&gt;Drew Furgiuele&amp;rsquo;s #sqlibirum post&lt;/a&gt;. That blog post is over &lt;a href="https://am2.co/2018/02/13/tsql-tuesday-99-sql-tourism/"&gt;here&lt;/a&gt;. This post is for the &amp;ldquo;Door Number 2&amp;rdquo; option is to talk about his Bad Habits series&amp;ndash;I&amp;rsquo;ve opted to bring up a topic Aaron hasn&amp;rsquo;t blogged about: tabs vs spaces.&lt;/p&gt;</description></item><item><title>TSQL Tuesday #99: SQL Tourism</title><link>https://am2.co/2018/02/13/tsql-tuesday-99-sql-tourism/</link><pubDate>Tue, 13 Feb 2018 07:00:45 -0500</pubDate><guid>https://am2.co/2018/02/13/tsql-tuesday-99-sql-tourism/</guid><description>&lt;p&gt;&lt;a href="https://sqlblog.org/2018/02/06/t-sql-tuesday-99"&gt;&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" alt="TSQL2SDAY" width="300" height="300" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;blockquote&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener noreferrer"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Aaron Bertrand&lt;/strong&gt; (&lt;a href="https://sqlblog.org/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt; | &lt;a href="https://twitter.com/aaronbertrand" target="_blank" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;). The topic: &lt;strong&gt;&lt;a href="https://sqlblog.org/2018/02/06/t-sql-tuesday-99" target="_blank" rel="noopener noreferrer"&gt;Dealer's Choice (Door Number 1: #sqlibrium) &lt;/a&gt;&lt;/strong&gt;&lt;/blockquote&gt;&#10;When I was a kid, &lt;a href="http://amzn.to/2GaEWjH" target="_blank" rel="noopener noreferrer"&gt;Choose Your Own Adventure books&lt;/a&gt; were overwhelming because I wanted to explore every possible option--some things never change. This month for T-SQL Tuesday, Aaron offers two blogging options and I've chosen to do both. "Door Number 1" is a challenge to write about what you do in your free time, inspired by &lt;a href="http://port1433.com/2017/12/13/keeping-sqlibirum-looking-back-on-what-mattered-most-this-year/" target="_blank" rel="noopener noreferrer"&gt;Drew Furgiuele's #sqlibirum post&lt;/a&gt;. That blog post is below. My other post is for the "Door Number 2" option is to talk about his Bad Habits series--I've opted to bring up a topic Aaron hasn't blogged about: &lt;a href="https://am2.co/2018/02/13/tsql-tuesday-99-tabs-vs-spaces/"&gt;tabs vs spaces&lt;/a&gt;.&#10;## SQL Tourism? What's that?&#10;I made it the term, but it's a very real thing. When I started travelling to speak at SQL Server events, I committed that I would make the most of it. To me, that means a lot more than just attending the event where I'm speaking. Sure, I want to learn and network at the event, but it means more than that, too. It means actually seeing the city where I'm speaking. It means enjoying the *entire* trip. It means making new friends, and connecting with old friends. Sometimes, it even means bringing my husband with me.&#10;&lt;p&gt;I work really hard. Some days I&amp;rsquo;m at my desk before 7:30, and working again after dinner until bedtime. My blog doesn&amp;rsquo;t write itself&amp;ndash;most posts are written nights &amp;amp; weekends after I&amp;rsquo;ve finished my work obligations for my paying work. That makes it really important to have some down time when I can. When Drew Furgiuele (&lt;a href="http://port1433.com/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt; | &lt;a href="http://twitter.com/pittfurg" target="_blank" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;) posted his &lt;a href="http://port1433.com/2017/12/13/keeping-sqlibirum-looking-back-on-what-mattered-most-this-year/" target="_blank" rel="noopener noreferrer"&gt;#sqlibrium post&lt;/a&gt;, it really struck me, because it&amp;rsquo;s something that a lot of us struggle with&amp;ndash;remembering to strike that balance between work and life.&lt;/p&gt;</description></item><item><title>Parsing file names from paths using T-SQL</title><link>https://am2.co/2018/01/17/parsing-file-names-paths-using-t-sql/</link><pubDate>Wed, 17 Jan 2018 07:00:40 -0500</pubDate><guid>https://am2.co/2018/01/17/parsing-file-names-paths-using-t-sql/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="https://www.youtube.com/watch?v=ijTEn2q-jFM"&gt;&lt;img class="wp-image-1265" src="https://am2.co/wp-content/uploads/maarten-van-den-heuvel-73123-300x200.jpg" alt="" width="400" height="267" /&gt;&lt;/a&gt; These files are way neater than the ones on my laptop.&lt;/figure&gt;&#10;&lt;p&gt;SQL Server is great at a lot of things. I spend a lot of time blogging about all the cool things that SQL Server does. But (you knew there was a &amp;ldquo;but&amp;rdquo;, didn&amp;rsquo;t you) SQL Server isn&amp;rsquo;t great at everything. Lets write about something that SQL Server is bad at.&lt;/p&gt;</description></item><item><title>Finding active transactions</title><link>https://am2.co/2018/01/02/finding-active-transactions/</link><pubDate>Tue, 02 Jan 2018 09:04:07 -0500</pubDate><guid>https://am2.co/2018/01/02/finding-active-transactions/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="http://amzn.to/2CDwuZP"&gt;&lt;img class="wp-image-1249" src="https://am2.co/wp-content/uploads/monika-grabkowska-452366-200x300.jpg" alt="" width="400" height="600" /&gt;&lt;/a&gt; Confessions of a carbaholic: When I start thinking about `ROLLBACK`, I start thinking about rolls.&lt;/figure&gt;&#10;&lt;p&gt;Have you ever forgot to commit a transaction? Maybe you&amp;rsquo;ve even &lt;a href="https://am2.co/2017/10/26/finding-leader-blocker/"&gt;left for lunch&lt;/a&gt; and caused a problem while you were gone. Uncommitted transactions can cause all sorts of problems&amp;ndash;not just blocking, but it can affect your Availability Groups &amp;amp; Mirroring, your TempDB version store if you&amp;rsquo;re using one of the snapshot &lt;a href="https://www.sql.kiwi/2014/07/isolation-levels/" target="_blank" rel="noopener noreferrer"&gt;isolation levels&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Alerting on SQL Server Blocking</title><link>https://am2.co/2017/12/18/alerting-sql-server-blocking/</link><pubDate>Mon, 18 Dec 2017 09:00:02 -0500</pubDate><guid>https://am2.co/2017/12/18/alerting-sql-server-blocking/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:350px"&gt;&lt;a href="https://www.youtube.com/watch?v=KLWLTs90_po"&gt;&lt;img class="wp-image-1233" src="https://am2.co/wp-content/uploads/TrafficIntersection-683x1024.jpg" alt="" width="350" height="525" /&gt;&lt;/a&gt; When blocking becomes excessive, it can cause problems. Are your blocks excessive?&lt;/figure&gt;&#10;&lt;p&gt;Identifying blocking is one of the most basic things that a DBA should be monitoring for. I previously wrote about how to &lt;a href="https://am2.co/2017/10/26/finding-leader-blocker/"&gt;identify blocking in SQL Server and find the leading blocker&lt;/a&gt;. Recently, my friend Jim Donahoe (&lt;a href="http://sqlflipflopsdba.com/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt; | &lt;a href="https://twitter.com/SQLFlipFlopsDBA" target="_blank" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;) asked me about setting up email alerts related to blocking, which prompted me to clean up some additional code I have that does just this. If you haven&amp;rsquo;t already read &lt;a href="https://am2.co/2017/10/26/finding-leader-blocker/"&gt;my previous post&lt;/a&gt;, you should probably do that now.&lt;/p&gt;</description></item><item><title>Finding the Leader Blocker</title><link>https://am2.co/2017/10/26/finding-leader-blocker/</link><pubDate>Thu, 26 Oct 2017 23:55:09 -0400</pubDate><guid>https://am2.co/2017/10/26/finding-leader-blocker/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:500px"&gt;&lt;a href="https://www.youtube.com/watch?v=iHzzSao6ypE"&gt;&lt;img class="wp-image-1194" src="https://am2.co/wp-content/uploads/evgeny-tchebotarev-247145-300x200.jpg" alt="" width="500" height="334" /&gt;&lt;/a&gt; Who's at the front of the line blocking all the traffic?&lt;/figure&gt;&#10;&lt;p&gt;During the course of normal processing in a database, blocking happens. Blocking is &amp;ldquo;by design&amp;rdquo; because &lt;a href="https://en.wikipedia.org/wiki/ACID" target="_blank" rel="noopener noreferrer"&gt;your database is on ACID&lt;/a&gt;. In an OLTP database, most of your transactions are short in duration, so we expect blocking to also be short in duration. If blocking occurs for a long time, this can cause problems.&lt;/p&gt;</description></item><item><title>LOG_RATE_GOVERNOR Wait Stat</title><link>https://am2.co/2017/09/18/log_rate_governor-wait-stat/</link><pubDate>Mon, 18 Sep 2017 13:17:55 -0400</pubDate><guid>https://am2.co/2017/09/18/log_rate_governor-wait-stat/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/186211/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm noticing this wait stat on my Azure SQL database, and I've never seen it before. I've tried Googling this wait stat but haven't been able to come up with any good information on what this is, although I saw a couple mentions of it possibly being related to exceeding the Azure performance tier set for the database.&lt;/p&gt;</description></item><item><title>Rebuild Very Large Primary Key Index</title><link>https://am2.co/2017/09/02/rebuild-very-large-primary-key-index/</link><pubDate>Sat, 02 Sep 2017 22:40:43 -0400</pubDate><guid>https://am2.co/2017/09/02/rebuild-very-large-primary-key-index/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/184973/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a SQL database that is hosted on Azure. The problem is that the size is getting out of control, I can see up to 99% fragmentation in the Primary Key clustered indexes.&lt;/p&gt;&#10;&lt;p&gt;I'm able to rebuild all other indexes with &lt;code&gt;online=on&lt;/code&gt; option and it won't affect performance. The size of one of the PK Clustered indexes is greater than 200GB, and for this one a &lt;code&gt;REBUILD...WITH (ONLINE=ON)&lt;/code&gt; causes locking.&lt;/p&gt;</description></item><item><title>Multi-Statement TVFs in Dynamics CRM</title><link>https://am2.co/2017/08/22/multi-statement-tvfs-in-dynamics-crm/</link><pubDate>Tue, 22 Aug 2017 13:19:18 -0400</pubDate><guid>https://am2.co/2017/08/22/multi-statement-tvfs-in-dynamics-crm/</guid><description>&lt;p&gt;If you&amp;rsquo;re familiar with supporting the database behind Microsoft Dynamics CRM, you probably know that it&amp;rsquo;s not the fastest-performing database. Honestly, that shouldn&amp;rsquo;t be a surprise&amp;ndash;it&amp;rsquo;s not designed to be a screaming-fast database. It&amp;rsquo;s designed to be a &lt;em&gt;flexible&lt;/em&gt; database. Most Customer Relationship Management (CRM) systems are designed to be flexible so that they can meet the needs of many businesses in many industries with vastly different business requirements. They put those requirements ahead of database performance. That&amp;rsquo;s probably smart business, but I&amp;rsquo;m not a business person&amp;ndash;I&amp;rsquo;m a database person. My experience with Dynamics CRM is when people come to me and say&lt;/p&gt;</description></item><item><title>Query a view in a procedure in which the view name is a variable</title><link>https://am2.co/2017/08/16/query-a-view-in-a-procedure-in-which-the-view-name-is-a-variable/</link><pubDate>Wed, 16 Aug 2017 18:18:49 -0400</pubDate><guid>https://am2.co/2017/08/16/query-a-view-in-a-procedure-in-which-the-view-name-is-a-variable/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/183661/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;My problem: I have a set of views from which I want to query dynamically.&#10;I want to load the view names by &lt;strong&gt;&lt;code&gt;SELECT * from sys.all_views&lt;/code&gt;&lt;/strong&gt; into a cursor (let's call it &lt;code&gt;view_cursor&lt;/code&gt;) and then do something like this in a procedure:&lt;/p&gt;</description></item><item><title>Can SQL Server 2016 log files be applied on SQL Server 2012</title><link>https://am2.co/2017/08/15/can-sql-server-2016-log-files-be-applied-on-sql-server-2012/</link><pubDate>Tue, 15 Aug 2017 03:53:35 -0400</pubDate><guid>https://am2.co/2017/08/15/can-sql-server-2016-log-files-be-applied-on-sql-server-2012/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/183494/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This is in relation to a rollback scenario from a 2012 -&gt; 2016 upgrade.&lt;/p&gt;&#10;&lt;p&gt;The scenario is that the SQL Server 2012 database is restored onto 2016 and log files applied until it is up to date. Then production systems are cut over to 2016. Database is kept at compatibility level for 2012. Subsequently, incremental logs from the 2016 instance are kept until the need to roll back (let's say 8 hours worth).&lt;/p&gt;</description></item><item><title>Reconnect "not connected" query windows in SSMS to original connection</title><link>https://am2.co/2017/08/14/reconnect-not-connected-query-windows-in-ssms-to-original-connection/</link><pubDate>Mon, 14 Aug 2017 14:20:38 -0400</pubDate><guid>https://am2.co/2017/08/14/reconnect-not-connected-query-windows-in-ssms-to-original-connection/</guid><description>&lt;!-- REPLACE:&#10;Question ID: 183432&#10;Asker Name: David Hiltenbrand&#10;Asker ID: 132635&#10;Question Date: 2017-08-14&#10;&#10;Answer ID: 183434&#10;Answer Date: 2017-08-14&#10;&#10;--&gt;&#10;&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/183432/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Is there a simple way to reconnect a query window that is &amp;ldquo;not connected&amp;rdquo; to the original connection that was used by that query without manually picking the server name needed? If I click the Connect button on the SQL Editor toolbar or right click -&amp;gt; Connection -&amp;gt; Connect&amp;hellip; it defaults the server name to the last connection I used in that SSMS session, not to the last connection used by that specific query window.&lt;/p&gt;</description></item><item><title>SQL Server FCI won't start after OS Upgrade</title><link>https://am2.co/2017/07/06/sql-server-fci-wont-start-after-os-upgrade/</link><pubDate>Thu, 06 Jul 2017 22:25:48 -0400</pubDate><guid>https://am2.co/2017/07/06/sql-server-fci-wont-start-after-os-upgrade/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/178196/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a two node sql server 2008 r2 cluster that we just did an OS upgrade from windows 2008 r2 to windows 2012 r2, the OS upgrade was done in place so the SQL Server Installation stayed in tack. The cluster role won't come back online saying it's couldn't find any IP address that this instance depends on. &lt;/p&gt;</description></item><item><title>What’s wrong with DELETE EXISTS?</title><link>https://am2.co/2017/06/30/whats-wrong-delete-exists/</link><pubDate>Fri, 30 Jun 2017 14:26:41 -0400</pubDate><guid>https://am2.co/2017/06/30/whats-wrong-delete-exists/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:300px"&gt;&lt;a href="https://archive.org/details/msdos_Number_Munchers_1990"&gt;&lt;img class="wp-image-1060 size-medium" src="https://am2.co/wp-content/uploads/NumberMunchers-300x187.png" alt="" width="300" height="187" /&gt;&lt;/a&gt; I loved playing Number Munchers on my Apple IIc&lt;/figure&gt;&#10;&lt;p&gt;This morning, when I logged into Twitter, the tweet at the top of my timeline was from Shane O&amp;rsquo;Neill (&lt;a href="https://nocolumnname.wordpress.com/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|&lt;a href="https://www.twitter.com/SOZDBA" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). It was to his blog post, &lt;a href="https://nocolumnname.wordpress.com/2017/06/30/shane-whats-wrong-with-delete-exists/" target="_blank" rel="noopener"&gt;Shane, What&amp;rsquo;s wrong with DELETE EXISTS?&lt;/a&gt;.  It&amp;rsquo;s not that unusual that Shane would talk to himself in the third person, but I was intrigued by the title.&lt;/p&gt;</description></item><item><title>Why Best Practices Exist: Learning from others' mistakes</title><link>https://am2.co/2017/06/28/best-practices-exist-learning-others-mistakes/</link><pubDate>Wed, 28 Jun 2017 20:00:11 -0400</pubDate><guid>https://am2.co/2017/06/28/best-practices-exist-learning-others-mistakes/</guid><description>&lt;p&gt;The latest malware to make the headlines is really interesting to me. It&amp;rsquo;s a ransomware worm called &lt;strong&gt;Petya&lt;/strong&gt;. Ransomware is particularly interesting to me as a DBA, because DBAs are responsible for keeping data safe, and ransomware is specifically designed to destroy your data. I&amp;rsquo;m not a security expert, and I don&amp;rsquo;t even pretend I am&amp;ndash;but security is something we should all be interested in.&lt;/p&gt;</description></item><item><title>Spread workload with always on high availability groups</title><link>https://am2.co/2017/06/27/spread-workload-with-always-on-high-availability-groups/</link><pubDate>Tue, 27 Jun 2017 14:04:54 -0400</pubDate><guid>https://am2.co/2017/06/27/spread-workload-with-always-on-high-availability-groups/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/24453807/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am wondering if it is possible to split up a very large query to have parts of it done on the secondary read only servers, or If this feature only allows me to run separate queries or scripts on the secondary servers. I would also like to know if anyone is using AlwaysOn High availability groups for this purpose, how is it working for you?&lt;/p&gt;</description></item><item><title>What is the row overhead when using Page Compression?</title><link>https://am2.co/2017/04/28/what-is-the-row-overhead-when-using-page-compression/</link><pubDate>Fri, 28 Apr 2017 11:23:41 -0400</pubDate><guid>https://am2.co/2017/04/28/what-is-the-row-overhead-when-using-page-compression/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/172252/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have created a table with 650 &lt;code&gt;Numeric(19,4)&lt;/code&gt; columns.&#10;When I switch on Page Compression, by running&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;fct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MyTable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;REBUILD&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WITH&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DATA_COMPRESSION&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PAGE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I get &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10; &lt;p&gt;Msg 1975, Level 16, State 1&lt;br&gt;Index 'PK_Mytable' row length exceeds the maximum permissible length of '8060' bytes. &lt;/p&gt;&#10;&lt;/div&gt;</description></item><item><title>Prevent Modification of dbo objects while allowing other schemas to be modified</title><link>https://am2.co/2017/04/20/prevent-modification-of-dbo-objects-while-allowing-other-schemas-to-be-modified/</link><pubDate>Thu, 20 Apr 2017 14:16:40 -0400</pubDate><guid>https://am2.co/2017/04/20/prevent-modification-of-dbo-objects-while-allowing-other-schemas-to-be-modified/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171523/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a vendor solution that uses a sql server (2008r2) database. We are allowed to do anything we want in our own schema, but cannot modify dbo objects without vendor permission. Any customization we make is in our own schema (cust). We have full control of this server and have always allowed sysadmin rights to any developer. Lately, I've noticed these rules have not been followed, so I want to see if I can set up permissions to stop this in the first place.&lt;/p&gt;</description></item><item><title>Why does it take so long to view logs on a server?</title><link>https://am2.co/2017/04/20/why-does-it-take-so-long-to-view-logs-on-a-server/</link><pubDate>Thu, 20 Apr 2017 12:20:14 -0400</pubDate><guid>https://am2.co/2017/04/20/why-does-it-take-so-long-to-view-logs-on-a-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171510/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am just trying to look up more verbose information for a maintenance plan task that failed. I open up the log file viewer and check the box to view the logs for my maintenance plan. There are no active filters besides that in this example. Then I play the waiting game.....&lt;/p&gt;</description></item><item><title>Load balancing reads SQL Server 2016 AG</title><link>https://am2.co/2017/04/19/load-balancing-reads-sql-server-2016-ag/</link><pubDate>Wed, 19 Apr 2017 18:21:44 -0400</pubDate><guid>https://am2.co/2017/04/19/load-balancing-reads-sql-server-2016-ag/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171438/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm trying to balance read traffic between two SQL Server 2016 Enterprise Edition instances (Primary and Secondary) using availability groups and the read only routing. &lt;/p&gt;&#10;&lt;p&gt;Here is my current setup:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;The servers are in AWS in two different AZ&lt;/li&gt;&#10;&lt;li&gt;The servers are in a failover cluster without shared storage&lt;/li&gt;&#10;&lt;li&gt;AG is enabled on both instances&lt;/li&gt;&#10;&lt;li&gt;The databases in an Availability Group have the "Readable Secondary" option set to Yes&lt;/li&gt;&#10;&lt;li&gt;I've setup the AG with the read only routing on both the current primary and secondary instances&lt;/li&gt;&#10;&lt;li&gt;Adding the read only switch in my application connection string allows me to route traffic to the secondary &lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Is there a way to have the AG Listener load balance read only traffic between the primary and secondary?&lt;/p&gt;</description></item><item><title>Troubleshooting Powershell errors from SQL Agent job</title><link>https://am2.co/2017/04/19/troubleshooting-powershell-errors-from-sql-agent-job/</link><pubDate>Wed, 19 Apr 2017 13:29:54 -0400</pubDate><guid>https://am2.co/2017/04/19/troubleshooting-powershell-errors-from-sql-agent-job/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171395/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a powershell script that I am trying to add in to a sql agent job, but the job step is failing with the following error&lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10;A job step received an error at line 1 in a PowerShell script. The corresponding line is 'import-module SQLPS -DisableNameChecking'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSSnapins.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.&#10;&lt;/div&gt;&#10;&lt;p&gt;I assumed that the error was being caused by differences in the module path, so I explicitly set the path via $env:PSModulePath to match the path of my powershell session where the code runs fine. I am pretty new to powershell, so any help you could provide would be appreciated&lt;/p&gt;</description></item><item><title>Transaction Replication on AlwaysOn</title><link>https://am2.co/2017/04/17/transaction-replication-on-alwayson/</link><pubDate>Mon, 17 Apr 2017 22:21:43 -0400</pubDate><guid>https://am2.co/2017/04/17/transaction-replication-on-alwayson/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171244/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In our AlwayOn environment I have two SQL servers 2014 Ent.edition (SERVER A, and SERVER B). I setup a transaction replication for [database A ], pointing to listener which shouldn't cause any issue if a failover happened. Tested, worked just fine after a failover, but when I shut off one of the servers in AOAG ,in test environment, replication stops working. There is no error on the replication monitor. For testing purpose,I have inserted few records on the database it works fine on AOAG, but on the Subscriber the data modification is not replicated until I bring up the other server. Once the server is up, then the replication start to work. I'm pretty sure, I might be missing something, this can't be this way by design. &lt;/p&gt;</description></item><item><title>How to take SQL Server databases backup using .bat script file with time stamp</title><link>https://am2.co/2017/04/17/how-to-take-sql-server-databases-backup-using-bat-script-file-with-time-stamp/</link><pubDate>Mon, 17 Apr 2017 13:24:49 -0400</pubDate><guid>https://am2.co/2017/04/17/how-to-take-sql-server-databases-backup-using-bat-script-file-with-time-stamp/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171196/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am using SQL Server Express edition, so there is no features for backup plan, I want to take databases backup using bat script, and create a scheduler to be run everyday. I have created .bat file but need to place a time stamp at the end of backup file like test_13_April_2017.&lt;/p&gt;</description></item><item><title>If the Database is in Readonly mode how can we drop/remove those unused roles</title><link>https://am2.co/2017/04/17/if-the-database-is-in-readonly-mode-how-can-we-drop-remove-those-unused-roles/</link><pubDate>Mon, 17 Apr 2017 11:03:22 -0400</pubDate><guid>https://am2.co/2017/04/17/if-the-database-is-in-readonly-mode-how-can-we-drop-remove-those-unused-roles/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171187/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In SQL Server, if the Database is in &lt;code&gt;Read_only&lt;/code&gt; mode, can we drop/remove unused roles? Please let me know.&lt;/p&gt;&#10;&lt;p&gt;Thanks in advance&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/171187/52344" rel="noopener" target="_blank"&gt;2017-04-17&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/109681" rel="noopener" target="_blank"&gt;Bharath Kuamr reddy&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;p&gt;If a database is in &lt;code&gt;READ_ONLY&lt;/code&gt; mode, it is &lt;strong&gt;completely&lt;/strong&gt; read-only. The read-only-ness is not limited to user data, but &lt;em&gt;anything&lt;/em&gt; contained in the database. This means that both DML commands (ie, &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;), and DDL commands (ie, &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;ALTER&lt;/code&gt;, &lt;code&gt;DROP&lt;/code&gt;) are prohibited. &lt;/p&gt;</description></item><item><title>Preventing SQL injection in dynamic SQL</title><link>https://am2.co/2017/04/14/preventing-sql-injection-in-dynamic-sql/</link><pubDate>Fri, 14 Apr 2017 08:29:34 -0400</pubDate><guid>https://am2.co/2017/04/14/preventing-sql-injection-in-dynamic-sql/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/170990/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Let's imagine a stored procedure that retreives data and do some kind of pagination. This procedure has some inputs describing which set of data we want and how we sort it.&lt;/p&gt;&#10;&lt;p&gt;Here is a very simple query, but let's take it as an example.&lt;/p&gt;</description></item><item><title>When setting up an AlwaysOn Availability Group, should the master database be one of the "Availability Databases"?</title><link>https://am2.co/2017/04/12/when-setting-up-an-alwayson-availability-group-should-the-master-database-be-one-of-the-availability-databases/</link><pubDate>Wed, 12 Apr 2017 17:44:16 -0400</pubDate><guid>https://am2.co/2017/04/12/when-setting-up-an-alwayson-availability-group-should-the-master-database-be-one-of-the-availability-databases/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/170856/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I just got a Sql Server 2016 Availability Group setup (A Primary, a Syncronous Secondary and a Async Secondary). I have five databases on the servers.&lt;/p&gt;&#10;&lt;p&gt;I setup an application to run queries against the server (using Entity Framework with a "failover partner" connection string.)&lt;/p&gt;</description></item><item><title>Releasing free space in mdf file to OS</title><link>https://am2.co/2017/04/10/releasing-free-space-in-mdf-file-to-os/</link><pubDate>Mon, 10 Apr 2017 13:29:43 -0400</pubDate><guid>https://am2.co/2017/04/10/releasing-free-space-in-mdf-file-to-os/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/170621/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have a 120GB database. There was table with 60GB of data which is useless and we have truncated it. &lt;/p&gt;&#10;&lt;p&gt;Now database size is 120GB with free space 60GB. The database will not grow up to 60GB in at least 3 months. So can we shrink the data file.&lt;/p&gt;</description></item><item><title>Transaction log growth during BACKUP</title><link>https://am2.co/2017/04/10/transaction-log-growth-backup/</link><pubDate>Mon, 10 Apr 2017 08:06:37 -0400</pubDate><guid>https://am2.co/2017/04/10/transaction-log-growth-backup/</guid><description>&lt;p&gt;Over on Stack Exchange, &lt;a href="http://dba.stackexchange.com/questions/169174/sql-server-2014-transaction-log-is-growing-very-fast" target="_blank"&gt;someone asked&lt;/a&gt; why their transaction log was growing very fast during a full backup. An interesting tidbit to this question is that the database is in &lt;code&gt;SIMPLE&lt;/code&gt; recovery &amp;ndash; so the log should stay tiny, right?&lt;/p&gt;&#10;&lt;p&gt;Wrong. While taking a full backup of the database, SQL Server is unable to reuse the transaction log for the duration of the backup, &lt;em&gt;even if the database is in &lt;code&gt;SIMPLE&lt;/code&gt; recovery&lt;/em&gt;. If your database is very busy, or backups take a long period of time, this can require a large transaction log, &lt;em&gt;even if the database is in &lt;code&gt;SIMPLE&lt;/code&gt; recovery&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>SQL Triggers not preventing insert</title><link>https://am2.co/2017/04/10/sql-triggers-not-preventing-insert/</link><pubDate>Mon, 10 Apr 2017 00:53:58 -0400</pubDate><guid>https://am2.co/2017/04/10/sql-triggers-not-preventing-insert/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/170564/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am having trouble getting a trigger to work. What it needs to do is to prevent any customer with last name Glass from being inserted into the database. This is what I have:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TRIGGER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;no_last_name_glass_trg&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;AFTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;DECLARE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;CUSTOMER_LAST&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;CUSTOMER_LAST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;INSERTED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_last&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;INSERTED&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;CUSTOMER_LAST&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Glass&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ROLLBACK&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RAISERROR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Applicant Glass Denied&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The issue is when I add customers with last name of Glass, it inserts without throwing an error. Any ideas? I can make it work in Oracle, but the same method does not work in MS SQL.&lt;/p&gt;</description></item><item><title>Why do I have to backup a transaction log twice for it to shrink?</title><link>https://am2.co/2017/04/07/why-do-i-have-to-backup-a-transaction-log-twice-for-it-to-shrink/</link><pubDate>Fri, 07 Apr 2017 06:42:17 -0400</pubDate><guid>https://am2.co/2017/04/07/why-do-i-have-to-backup-a-transaction-log-twice-for-it-to-shrink/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/169408/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This question was attempted twice on experts-exchange with no real answer.&lt;/p&gt;&#10;&lt;p&gt;I know that I should not shrink the log file - that is not the question.&lt;/p&gt;&#10;&lt;p&gt;If you feel like answering that one should not do it- that has been confirmed many times yes and it is not the goal of this question.&lt;/p&gt;</description></item><item><title>Converting date stored as a varchar</title><link>https://am2.co/2017/04/06/converting-date-stored-as-a-varchar/</link><pubDate>Thu, 06 Apr 2017 10:00:51 -0400</pubDate><guid>https://am2.co/2017/04/06/converting-date-stored-as-a-varchar/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/169287/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm creating a query that has a column of dates stored as a VARCHAR in the format DD-MMM-YYYY.&lt;/p&gt;&#10;&lt;p&gt;Could you tell me how I can convert this into date format please?&lt;/p&gt;&#10;&lt;p&gt;I don't want to alter the original table in any way, as it's not mine to tinker!&lt;/p&gt;</description></item><item><title>Transaction log is growing very fast</title><link>https://am2.co/2017/04/05/transaction-log-is-growing-very-fast/</link><pubDate>Wed, 05 Apr 2017 19:45:50 -0400</pubDate><guid>https://am2.co/2017/04/05/transaction-log-is-growing-very-fast/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/169174/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;One of our SQL Server 2014 database transaction logs is growing very fast and I cannot find the root cause for this.&lt;/p&gt;&#10;&lt;p&gt;Database in Simple recovery mode. During full backup the log file grows to its limits (800GB) and backup fails.&lt;/p&gt;</description></item><item><title>Connecting to ReadOnly Secondary Replica of SQL Server via the Listener by Default</title><link>https://am2.co/2017/03/31/connecting-to-readonly-secondary-replica-of-sql-server-via-the-listener-by-default/</link><pubDate>Fri, 31 Mar 2017 00:56:41 -0400</pubDate><guid>https://am2.co/2017/03/31/connecting-to-readonly-secondary-replica-of-sql-server-via-the-listener-by-default/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/168708/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have the ApplicationIntent=ReadOnly properly routing our users to the Secondary ReadOnly replica. Is there a way to make this the default behavior?&lt;/p&gt;&#10;&lt;p&gt;Apparently the default behavior seems to be ReadWrite, and if you don't specify an ApplicationIntent it will redirect to the Primary server.&lt;/p&gt;</description></item><item><title>What the heck is a DTU?</title><link>https://am2.co/2017/03/30/what-the-heck-is-a-dtu/</link><pubDate>Thu, 30 Mar 2017 09:42:18 -0400</pubDate><guid>https://am2.co/2017/03/30/what-the-heck-is-a-dtu/</guid><description>&lt;img src="https://am2.co/wp-content/uploads/dtu-fire.png" style="width:132px;float:right;margin:-15px 0px 12px 22px" alt="A Database Thermal Unit measures the amount of CPU needed to raise the temperature of a data center by 1 degree"&gt;&#10;&lt;h2 id="no-seriously-what-is-a-dtu"&gt;No, seriously. What is a DTU?&lt;/h2&gt;&#10;&lt;p&gt;When you&amp;rsquo;re deploying any application, one of the first questions that comes up is &amp;ldquo;What will this cost?&amp;rdquo; Most of us have gone through this sort of exercise for sizing a SQL Server installation at some point, but what if you&amp;rsquo;re deploying to the cloud? With Azure IaaS deployments, not much has changed&amp;ndash;you&amp;rsquo;re still building a server based on CPU count, some amount of memory, and configuring storage to give you enough IOPS for your workload. However, when you make the jump to PaaS, Azure SQL Database is sized with different &lt;a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-service-tiers" target="_blank" rel="noopener noreferrer"&gt;service tiers&lt;/a&gt;, where performance is measured in DTUs. &lt;strong&gt;What the heck is a DTU?&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Blogging at SQLPerformance.com</title><link>https://am2.co/2017/03/30/guest-blogging-at-sqlperformance-com/</link><pubDate>Thu, 30 Mar 2017 09:40:00 -0400</pubDate><guid>https://am2.co/2017/03/30/guest-blogging-at-sqlperformance-com/</guid><description>&lt;p&gt;&lt;a href="https://am2.co/wp-content/uploads/SQLPerfLogo-SO.png"&gt;&lt;img class="alignright size-medium wp-image-975" src="https://am2.co/wp-content/uploads/SQLPerfLogo-SO-300x118.png" alt="" width="300" height="118" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;As part of my role on the &lt;a href="https://www.SentryOne.com" target="_blank"&gt;SentryOne&lt;/a&gt; Product Advisory Council (PAC), I&amp;rsquo;m going to occasionally be contributing posts over at &lt;a href="https://sqlperformance.com/" target="_blank"&gt;SQLPerformance.com&lt;/a&gt;. Today, my first post was published: &lt;a href="https://am2.co/2017/03/30/what-the-heck-is-a-dtu/"&gt;What the heck is a DTU?&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;SQLPerformance.com focuses on providing innovative and practical solutions for improving SQL Server performance. The site has long been a source of learning for me, and I&amp;rsquo;m incredibly excited to now be providing my own content to the site. Worry not, faithful reader! I&amp;rsquo;ll still be blogging here, at am2.co, but you can expect some of my performance-oriented posts to live over there.&lt;/p&gt;</description></item><item><title>SQLSaturday Boston 2017 Roundup</title><link>https://am2.co/2017/02/28/sqlsaturday-boston-2017-roundup/</link><pubDate>Tue, 28 Feb 2017 07:00:45 -0500</pubDate><guid>https://am2.co/2017/02/28/sqlsaturday-boston-2017-roundup/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="https://www.youtube.com/watch?v=u1qN6gLbUMw"&gt;&lt;img class="wp-image-895" src="https://am2.co/wp-content/uploads/sqlsat585-300x146.png" width="400" height="195" /&gt;&lt;/a&gt; SQL Saturday Night Fever&lt;/figure&gt;&#10;&lt;p&gt;SQLSaturday Boston was February 25. I was invited into the organizing team in 2015, and this was my third time helping to put together the event. But this time was different. This time, I was running the show. I wanted to do a quick round-up of some of the things we did differently this time&amp;ndash;I&amp;rsquo;ll dive right in with the most important thing first&amp;hellip;&lt;/p&gt;</description></item><item><title>Risks of manual failover in Always On Availability Groups</title><link>https://am2.co/2017/02/09/risks-of-manual-failover-in-always-on-availability-groups/</link><pubDate>Thu, 09 Feb 2017 19:11:24 -0500</pubDate><guid>https://am2.co/2017/02/09/risks-of-manual-failover-in-always-on-availability-groups/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/163787/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In my environment, I have SQL 2014 with Always On Availability Group for databases in asynchronous with manual fail over.&lt;/p&gt;&#10;&lt;p&gt;We have 1 primary and 2 secondary replicas--secondary1 and sec2.&lt;/p&gt;&#10;&lt;p&gt;I have to do failover from primary to secondary1. I know some data loss will happen as it is a forced failover.&lt;/p&gt;</description></item><item><title>Customizing SSRS Sender Address</title><link>https://am2.co/2017/02/06/custom-ssrs-sender-address/</link><pubDate>Mon, 06 Feb 2017 20:19:43 -0500</pubDate><guid>https://am2.co/2017/02/06/custom-ssrs-sender-address/</guid><description>&lt;p&gt;In SQL Server Reporting Services (SSRS), you can configure the sender address for email subscriptions at the instance level. This means that every email sent from your SSRS server will come from the same address. (On each subscription, you can optionally supply a Reply-To address, which allows users to reply to the email directly, and respond to the right person&amp;hellip;but that&amp;rsquo;s not why we&amp;rsquo;re here.)&lt;/p&gt;</description></item><item><title>SQL Agent Job Logs - Can't get the Error Log</title><link>https://am2.co/2017/01/25/sql-agent-job-logs-cant-get-the-error-log/</link><pubDate>Wed, 25 Jan 2017 09:59:18 -0500</pubDate><guid>https://am2.co/2017/01/25/sql-agent-job-logs-cant-get-the-error-log/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/177204/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I've some logs that I want to extract to a report in order to get the SQL_Agent_Jobs status that runs during the night. If the Job fails then I want to receive the Error Log in a table. I am trying to get that information with this query:&lt;/p&gt;</description></item><item><title>Building a Twitter-bot RSS Aggregator</title><link>https://am2.co/2017/01/11/building-twitter-bot-rss-aggregator/</link><pubDate>Wed, 11 Jan 2017 23:13:34 -0500</pubDate><guid>https://am2.co/2017/01/11/building-twitter-bot-rss-aggregator/</guid><description>&lt;h2 id="i-hate-rssreaders"&gt;I hate RSS readers&lt;/h2&gt;&#10;&lt;figure class="wp-caption alignright" style="max-width:512px"&gt;&lt;a href="https://www.youtube.com/watch?v=BxtKAvv1hLA"&gt;&lt;img class="wp-image-824" src="https://am2.co/wp-content/uploads/BotLove-1024x709.jpg" width="512" height="354" /&gt;&lt;/a&gt; I love my new bot&lt;/figure&gt;&#10;&lt;p&gt;For some reason, about once a year, I go hunting for a new RSS reader so I can keep track of blogs that I like to read.  It&amp;rsquo;s always the same process:&lt;/p&gt;&#10;&lt;ol&gt;&#10; &#9;&lt;li&gt;Dig through reviews to find an app that I think I will love.&lt;/li&gt;&#10; &#9;&lt;li&gt;Come up with a list of blogs that I like to read.&lt;/li&gt;&#10; &#9;&lt;li&gt;Install and configure RSS reader app.&lt;/li&gt;&#10; &#9;&lt;li&gt;Spend the night reading blog posts.&lt;/li&gt;&#10; &#9;&lt;li&gt;Use app for a week.&lt;/li&gt;&#10; &#9;&lt;li&gt;Never open RSS reader app again.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;Well, it's time to &lt;a href="https://www.youtube.com/watch?v=ZjfB4qDx3RM" target="_blank" rel="noopener noreferrer"&gt;stop the insanity&lt;/a&gt;. Its time to stop doing the same thing over and over again, hoping it will work this time. Its time to find a solution that really works.&#10;&lt;p&gt;Before I can find something that works, I need to think about&lt;/p&gt;</description></item><item><title>Nonclustered index storage on clustered columnstore</title><link>https://am2.co/2017/01/06/nonclustered-index-storage-on-clustered-columnstore/</link><pubDate>Fri, 06 Jan 2017 11:47:02 -0500</pubDate><guid>https://am2.co/2017/01/06/nonclustered-index-storage-on-clustered-columnstore/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/160158/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In SQL Server, a non-unique nonclustered index on a rowstore table incorporates the base object&amp;rsquo;s &lt;em&gt;bookmark&lt;/em&gt; (RID or clustering key) at all levels of the nonclustered index structure. The bookmark is stored as part of the nonclustered index &lt;em&gt;key&lt;/em&gt; at all index levels.&lt;/p&gt;</description></item><item><title>Cannot restore azure database to local due to missing master key</title><link>https://am2.co/2017/01/04/cannot-restore-azure-database-to-local-due-to-missing-master-key/</link><pubDate>Wed, 04 Jan 2017 09:26:09 -0500</pubDate><guid>https://am2.co/2017/01/04/cannot-restore-azure-database-to-local-due-to-missing-master-key/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/160007/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I create a bacpac from azure and restore to my local on-prem server. However, it throws an error like “Please create a master key in the database or open the master key in the session before performing this operation”. The reason is one of the column in the table is encrypted. I don’t know how to restore the database from azure with master key and certificate etc. Do you know what I could do?&lt;/p&gt;</description></item><item><title>How often to update SQL Server?</title><link>https://am2.co/2017/01/02/how-often-to-update-sql-server/</link><pubDate>Mon, 02 Jan 2017 19:10:39 -0500</pubDate><guid>https://am2.co/2017/01/02/how-often-to-update-sql-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/159754/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am a new DBA at a company that has never had a DBA before me. SQL Servers are never upgraded unless it is part of a Windows Update on the server. Service Packs (or CUs) are never installed. We have a mix of versions from 2000 to 2014.&lt;/p&gt;</description></item><item><title>Does the 'reads' column in SQL Profiler mean the same as IOPS?</title><link>https://am2.co/2016/12/21/does-the-reads-column-in-sql-profiler-mean-the-same-as-iops/</link><pubDate>Wed, 21 Dec 2016 11:25:14 -0500</pubDate><guid>https://am2.co/2016/12/21/does-the-reads-column-in-sql-profiler-mean-the-same-as-iops/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/158797/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I just executed a query that went pretty fast and the SQL Profiler said it used 30.000 reads.&#10;Now I'm looking at this page: &lt;a href="https://cloud.google.com/compute/docs/disks/performance" rel="nofollow noreferrer"&gt;https://cloud.google.com/compute/docs/disks/performance&lt;/a&gt; and see that a standard persistent disk has 3000 reads IOPS.&lt;/p&gt;&#10;&lt;p&gt;Does that mean that my query would take 10 seconds when run there? Or does &lt;code&gt;SQL reads&lt;/code&gt; and &lt;code&gt;read IOPS&lt;/code&gt; mean a totally different thing?&lt;/p&gt;</description></item><item><title>What is the MySQL equivalent of SQL Server 2016 Always Encrypted technology?</title><link>https://am2.co/2016/12/20/what-is-the-mysql-equivalent-of-sql-server-2016-always-encrypted-technology/</link><pubDate>Tue, 20 Dec 2016 18:04:46 -0500</pubDate><guid>https://am2.co/2016/12/20/what-is-the-mysql-equivalent-of-sql-server-2016-always-encrypted-technology/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/158725/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;What is the MySQL equivalent of SQL Server 2016 Always Encrypted technology or is there anything similar in MySQL that can act as AE?&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/158725/52344" rel="noopener" target="_blank"&gt;2016-12-20&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/113328" rel="noopener" target="_blank"&gt;dwkd&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;p&gt;The Always Encrypted feature provides end-to-end encryption, which encrypts data both in-flight, and at rest. Data is encrypted &amp;amp; decrypted on the client at the driver. Data is encrypted everywhere except for on he client machine. This is one step beyond encryption at rest (which is handled in SQL Server by Transparent Data Encryption).&lt;/p&gt;</description></item><item><title>TSQL Tuesday #85: Backup + Recovery + ☁️</title><link>https://am2.co/2016/12/13/tsql-tuesday-85-backup-recovery/</link><pubDate>Tue, 13 Dec 2016 22:11:48 -0500</pubDate><guid>https://am2.co/2016/12/13/tsql-tuesday-85-backup-recovery/</guid><description>&lt;blockquote&gt;&lt;a href="https://sqlstudies.com/2016/12/06/4169/"&gt;&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" alt="TSQL2SDAY" width="300" height="300" /&gt;&lt;/a&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Kenneth Fisher&lt;/strong&gt; (&lt;a href="https://sqlstudies.com/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;| &lt;a href="https://twitter.com/sqlstudent144" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). The topic: &lt;strong&gt;&lt;a href="https://sqlstudies.com/2016/12/06/4169/" target="_blank" rel="noopener"&gt;Backup &amp;amp; Recovery&lt;/a&gt;&lt;/strong&gt;&lt;/blockquote&gt;&#10;## Your backups are my bread &amp;amp; butter&#10;Backup &amp;amp; recovery are a DBA's &lt;a href="https://en.wikipedia.org/wiki/Glossary_of_baseball_(B)#bread_and_butter" target="_blank" rel="noopener"&gt;bread &amp;amp; butter&lt;/a&gt;. I always tell people that if you can't restore from backup in an emergency, you should at least make sure your resume is up to date--you'll need it. Part of my approach to making sure I have foolproof backups is making sure my setup is scripted and fool-proof to configure. Traditionally, this has been as simple as some T-SQL scripts that create the &lt;a href="https://ola.hallengren.com/sql-server-backup.html"&gt;backup stored procedure&lt;/a&gt;, and create a few SQL Agent jobs.&#10;&lt;p&gt;The SQL Agent jobs would write to the NAS, use the company standard retention, and everything was set. No muss, no fuss.&lt;/p&gt;</description></item><item><title>How to add 1100 columns in SQL Server</title><link>https://am2.co/2016/12/04/how-to-add-1100-columns-in-sql-server/</link><pubDate>Sun, 04 Dec 2016 06:49:07 -0500</pubDate><guid>https://am2.co/2016/12/04/how-to-add-1100-columns-in-sql-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/157115/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need 1100 columns in a single table.I already have 928 columns in same table, now I need to add new 150 columns.&lt;/p&gt;&#10;&lt;p&gt;I know SQL Server allow maximum 1024 columns.&lt;/p&gt;&#10;&lt;p&gt;Now I will not create new table. If I create new table and join my require table, I need to make changes in many places and this is not possible for me. So I want to add all columns in same table(require table).I know this is so tough to execute this table but presently I need to serve this requirement.&lt;/p&gt;</description></item><item><title>December SQLSaturdays--DC &amp; Providence, RI</title><link>https://am2.co/2016/11/04/december-sqlsaturdays-2016/</link><pubDate>Fri, 04 Nov 2016 13:08:19 -0400</pubDate><guid>https://am2.co/2016/11/04/december-sqlsaturdays-2016/</guid><description>&lt;p&gt;Next month, I&amp;rsquo;ll be speaking at two SQLSaturday events.&lt;/p&gt;&#10;&lt;h3&gt;Washington, DC - &lt;a href="https://twitter.com/hashtag/sqlsatdc?f=tweets&amp;amp;vertical=default&amp;amp;src=hash" target="_blank" rel="noopener noreferrer"&gt;#SqlSat574&lt;/a&gt; - December 3, 2016&lt;/h3&gt;&#10;&lt;figure class="wp-caption alignright" style="max-width:300px"&gt;&lt;a href="https://www.google.com/logos/2010/pacman10-i.html"&gt;&lt;img class="wp-image-752 size-medium" src="https://am2.co/wp-content/uploads/PacManSan-300x200.png" alt="Being a DBA is like play Pac-San. Eat all the LUNs before the SAN Admin chases you away." width="300" height="200" /&gt;&lt;/a&gt; Being a DBA is like play Pac-San. Eat all the LUNs before the SAN Admin chases you away.&lt;/figure&gt;&#10;&lt;p&gt;The DC SQL Saturday was the first SQL Saturday I spoke at&amp;ndash;so this one will always be a special event for me. Hopefully, I&amp;rsquo;ll be able to speak at this event every year.&lt;/p&gt;</description></item><item><title>T-SQL Tuesday #83: Roundup</title><link>https://am2.co/2016/10/16/t-sql-tuesday-83-roundup/</link><pubDate>Sun, 16 Oct 2016 20:49:50 -0400</pubDate><guid>https://am2.co/2016/10/16/t-sql-tuesday-83-roundup/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=ImaYMoTi2g8"&gt;&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" alt="TSQL2SDAY" width="300" height="300" /&gt;&lt;/a&gt;For this month&amp;rsquo;s T-SQL Tuesday, I asked people to blog about &lt;a href="https://am2.co/2016/10/04/t-sql-tuesday-83/"&gt;the same old problems we&amp;rsquo;ve been dealing with for years&lt;/a&gt;. There were some great posts, including a batch of first-time contributors. You&amp;rsquo;ll notice some overlapping themes as you read through these responses&amp;ndash;I think those themes represent some of the biggest, most important problems we have (like being able to restore backups). Thanks for everyone who contributed this month!&lt;/p&gt;</description></item><item><title>T-SQL Tuesday #83: We're still dealing with the same problems</title><link>https://am2.co/2016/10/04/t-sql-tuesday-83/</link><pubDate>Tue, 04 Oct 2016 09:00:37 -0400</pubDate><guid>https://am2.co/2016/10/04/t-sql-tuesday-83/</guid><description>&lt;h3 id="what-is-t-sql-tuesday"&gt;What is T-SQL Tuesday?&lt;/h3&gt;&#10;&lt;p&gt;&lt;img class="alignright size-full wp-image-532" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" alt="TSQL2SDAY" width="300" height="300" /&gt;T-SQL Tuesday is a monthly blog party hosted by a different blogger each month. This blog party was started by Adam Machanic (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). You can take part by posting your own participating post that fits the topic of the month and follows the requirements below. Additionally, if you are interested in hosting a future T-SQL Tuesday, contact Adam Machanic on his blog.&lt;/p&gt;</description></item><item><title>Plan Explorer 3.0: More power and completely free</title><link>https://am2.co/2016/09/08/plan-explorer-3-0/</link><pubDate>Thu, 08 Sep 2016 11:00:04 -0400</pubDate><guid>https://am2.co/2016/09/08/plan-explorer-3-0/</guid><description>&lt;p&gt;Today, SQL Sentry &lt;a href="http://blogs.sqlsentry.com/greggonzalez/plan-explorer-pro-goes-free/" target="_blank"&gt;announced the release of Plan Explorer 3.0&lt;/a&gt;. There are a few big changes, so let&amp;rsquo;s dive right in.&lt;/p&gt;&#10;&lt;p&gt; &lt;/p&gt;&#10;&lt;h3 id="plan-explorer-just-got-free-er"&gt;Plan Explorer just got free-er&lt;/h3&gt;&#10;&lt;p&gt;&lt;img class="alignright size-full wp-image-649" src="https://am2.co/wp-content/uploads/SQLSentry-Logo-400x81.png" alt="SQLSentry-Logo-400x81" width="400" height="81" /&gt;Up until now, Plan Explorer was essentially a freemium product. There was the free edition (which was really awesome), or you could upgrade to Pro edition for some extra features (making it awesomer). With this release, everything is now included in a single edition, and it&amp;rsquo;s &lt;strong&gt;all 100% free&lt;/strong&gt;. Any feature that used to be Pro-only is now free. Multiple tabs, session history, opening deadlock files&amp;ndash;free, free, free. Any new features? You guessed it&amp;ndash;free.&lt;/p&gt;</description></item><item><title>AlwaysON Migrate from 2014 to 2016</title><link>https://am2.co/2016/09/01/alwayson-migrate-from-2014-to-2016/</link><pubDate>Thu, 01 Sep 2016 19:19:24 -0400</pubDate><guid>https://am2.co/2016/09/01/alwayson-migrate-from-2014-to-2016/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/148594/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have like 20 Listners on 2014 with approx 500 DBS, &lt;/p&gt;&#10;&lt;p&gt;what is the best way to migrate these with least downtime, effort&lt;/p&gt;&#10;&lt;p&gt;My idea is:&#10; Stop access&#10; Backup dbs&#10; Start restore dbs&#10; While restore is running:&#10; Drop AOG on 2014&#10; Create it on 2016&#10; Done&lt;/p&gt;</description></item><item><title>Podcast: Mirroring, Availability Groups, Replication, and Log shipping</title><link>https://am2.co/2016/08/31/podcast-mirroring-availability-groups-replication-log-shipping/</link><pubDate>Wed, 31 Aug 2016 09:29:03 -0400</pubDate><guid>https://am2.co/2016/08/31/podcast-mirroring-availability-groups-replication-log-shipping/</guid><description>&lt;p&gt;&lt;a href="http://sqldatapartners.com/podcast/"&gt;&lt;img class="alignright wp-image-621 size-medium" src="https://am2.co/wp-content/uploads/SQLDataPartnersPodcast-300x300.png" alt="SQL Data Partners Podcast" width="300" height="300" /&gt;&lt;/a&gt;Have you ever wondered what the best option is for making your data available in your environment? I was asked by Carlos L Chacon (&lt;a href="http://sqldatapartners.com/author/carlosjr/" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/CarlosLChacon" target="_blank"&gt;twitter&lt;/a&gt;) to be part of a panel on his podcast for an episode discussing some of the options&amp;ndash;availability groups, mirroring, log shipping, and replication. We cover each topic in detail and explain the positives and negatives of each one.&lt;/p&gt;</description></item><item><title>Is it possible to change the family_guid in MSSQL?</title><link>https://am2.co/2016/08/24/is-it-possible-to-change-the-family_guid-in-mssql/</link><pubDate>Wed, 24 Aug 2016 19:17:43 -0400</pubDate><guid>https://am2.co/2016/08/24/is-it-possible-to-change-the-family_guid-in-mssql/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/147801/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;So I have a bit of a problem with some databases I'm trying to migrate to amazon RDS&lt;/p&gt;&#10;&lt;p&gt;We have about 20 Databases that are all derivatives of others that all share the same &lt;code&gt;family_guid&lt;/code&gt; because they are based on backups of others. The problem is that amazon will not allow you to restore a DB that has the same &lt;code&gt;family_guid&lt;/code&gt; of another even if they are two separate databases. This is where my question comes in, Is it possible to change the guid or am I out of luck and will need to do some exports/imports on these databases.&lt;/p&gt;</description></item><item><title>SQL Server 2014 slow insert</title><link>https://am2.co/2016/08/24/sql-server-2014-slow-insert/</link><pubDate>Wed, 24 Aug 2016 16:21:43 -0400</pubDate><guid>https://am2.co/2016/08/24/sql-server-2014-slow-insert/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/147774/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a very strange slow insert issue, here I am providing the table structure, and the insert statement used.&lt;/p&gt;&#10;&lt;p&gt;The database is clean, contains no other tables, no indices, no constraints, no triggers.&lt;/p&gt;&#10;&lt;p&gt;I tested this on two different machines, with high speed SSD drives, 8 cores 3.5 GHz processors. The server can read IO up to 700MB/s and can write up to 300MB/s&lt;/p&gt;</description></item><item><title>Why is this explicit cast causing problems only with a Linked Server?</title><link>https://am2.co/2016/08/17/why-is-this-explicit-cast-causing-problems-only-with-a-linked-server/</link><pubDate>Wed, 17 Aug 2016 07:42:23 -0400</pubDate><guid>https://am2.co/2016/08/17/why-is-this-explicit-cast-causing-problems-only-with-a-linked-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/147039/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am querying data from a linked server through a view on the origin server.&#10;The view has to include a couple of standardized columns, such as &lt;code&gt;Created&lt;/code&gt;, &lt;code&gt;Modified&lt;/code&gt; and &lt;code&gt;Deleted&lt;/code&gt;, but in this case the table on the source server doesn't have any suitable info. The columns are therefore explicitly cast to their respective types. I updated the view, changing a column from &lt;/p&gt;</description></item><item><title>Does it ever make sense to have a clustered and non clustered index for the same column</title><link>https://am2.co/2016/08/16/does-it-ever-make-sense-to-have-a-clustered-and-non-clustered-index-for-the-same-column/</link><pubDate>Tue, 16 Aug 2016 22:08:55 -0400</pubDate><guid>https://am2.co/2016/08/16/does-it-ever-make-sense-to-have-a-clustered-and-non-clustered-index-for-the-same-column/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/147011/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Does it ever make sense to have a clustered and non clustered index for the same column&lt;/p&gt;&#10;&lt;p&gt;I inherited a database and a web service that goes with it.&lt;/p&gt;&#10;&lt;p&gt;Looking at the indexes for duplicates I see an two indexes that point at the same column (1 column and sorted the same way). One is clustered and one is not, that is the only difference I see.&lt;/p&gt;</description></item><item><title>I have 3 tables with dates to which I want to join to a date dimension table but it is returning many duplicates with left joins</title><link>https://am2.co/2016/08/16/i-have-3-tables-with-dates-to-which-i-want-to-join-to-a-date-dimension-table-but-it-is-returning-many-duplicates-with-left-joins/</link><pubDate>Tue, 16 Aug 2016 11:55:03 -0400</pubDate><guid>https://am2.co/2016/08/16/i-have-3-tables-with-dates-to-which-i-want-to-join-to-a-date-dimension-table-but-it-is-returning-many-duplicates-with-left-joins/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/38665777/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have 4 tables with dates to which I want to join to a date dimension table but it is returning many duplicates with left joins.&lt;/p&gt;&#10;&lt;p&gt;Tables are basically a date field which I want to count.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;mdate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;mordate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;fteam&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sdate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;fteam&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bdate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;fteam&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These are actually one table with the separate dates which I am joining 3 times to the dimension table to get one dataset. Also this table&lt;/p&gt;</description></item><item><title>Why is sql_text "select @@trancount" in open but sleeping transaction?</title><link>https://am2.co/2016/08/12/why-is-sql_text-select-trancount-in-open-but-sleeping-transaction/</link><pubDate>Fri, 12 Aug 2016 17:37:19 -0400</pubDate><guid>https://am2.co/2016/08/12/why-is-sql_text-select-trancount-in-open-but-sleeping-transaction/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/146654/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Using SQL Server Management Studio, open a query window and execute&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TRAN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In another window execute&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sysprocesses&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;cross&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dm_exec_sql_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sql_handle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;sleeping&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;open_tran&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I see &lt;code&gt;select @@trancount&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;What's up with this? Who's counting transactions? Is this a Management Studio thing?&lt;/p&gt;</description></item><item><title>What is the benefit of having multiple databases in the same Availability Group vs single AG per database</title><link>https://am2.co/2016/08/08/what-is-the-benefit-of-having-multiple-databases-in-the-same-availability-group-vs-single-ag-per-database/</link><pubDate>Mon, 08 Aug 2016 06:11:50 -0400</pubDate><guid>https://am2.co/2016/08/08/what-is-the-benefit-of-having-multiple-databases-in-the-same-availability-group-vs-single-ag-per-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/146226/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We are planning a migration from current mirroring architecture to Availability Groups for several databases. For every Database we have defined the primary/secondary replica configuration. &lt;/p&gt;&#10;&lt;p&gt;The question that I'm unsure is: do we need to group the databases with the same primary/secondary configuration into the same AG, or use one AG per Database. What are pros&amp;amp;cons of having individual AGs vs AG with multiple databases? Is there a best practice to determine if a database needs its own AG or can be combined with others? Any performance or failover advantages?&lt;/p&gt;</description></item><item><title>Will a SELECT . . . INTO use short-circuit evaluation for a COALESCE?</title><link>https://am2.co/2016/08/02/will-a-select-into-use-short-circuit-evaluation-for-a-coalesce/</link><pubDate>Tue, 02 Aug 2016 14:45:55 -0400</pubDate><guid>https://am2.co/2016/08/02/will-a-select-into-use-short-circuit-evaluation-for-a-coalesce/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/145644/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm building a stored proc that can take in two separate values that each can be used to identify a single record. One of these values may be null.&lt;/p&gt;&#10;&lt;p&gt;My logic is as follows: if &lt;code&gt;IN_ORDER_ID&lt;/code&gt; is not NULL, save it to &lt;code&gt;V_ORDER_ID&lt;/code&gt;. If it is NULL, then retrieve &lt;code&gt;ORDER_ID&lt;/code&gt; with a query and save that to &lt;code&gt;V_ORDER_ID&lt;/code&gt;. &lt;code&gt;V_ORDER_ID&lt;/code&gt; is then used in the rest of the procedure.&lt;/p&gt;</description></item><item><title>Job hunting for database professionals</title><link>https://am2.co/2016/07/19/job-hunting-database-professionals/</link><pubDate>Tue, 19 Jul 2016 10:00:44 -0400</pubDate><guid>https://am2.co/2016/07/19/job-hunting-database-professionals/</guid><description>&lt;p&gt;Like most people, I&amp;rsquo;ve changed jobs a few times in my life. My path from teenage grocery store cashier to Database Architect was a complicated and multi-step journey. During that journey, I&amp;rsquo;ve made some good decisions, and some bad decisions. If you&amp;rsquo;re like most tech folks, you&amp;rsquo;ve probably had a similar experience.&lt;/p&gt;</description></item><item><title>Moving SSRS Reports between servers</title><link>https://am2.co/2016/06/29/moving-ssrs-reports-servers/</link><pubDate>Wed, 29 Jun 2016 12:30:42 -0400</pubDate><guid>https://am2.co/2016/06/29/moving-ssrs-reports-servers/</guid><description>&lt;p&gt;Today, my friend Derik Hammer (&lt;a href="http://www.sqlhammer.com" target="_blank"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/SQLHammer/" target="_blank"&gt;twitter&lt;/a&gt;) asked about moving SSRS reports between (versions and) instances of SSRS:&lt;/p&gt;&#10;&lt;div class="tweet-card" role="group" aria-label="Archived tweet by Derik Hammer"&gt;&#10; &lt;div class="tweet-card__header"&gt;&lt;img class="tweet-card__avatar" src="https://am2.co/images/tweet-profiles/derik-hammer.png" alt="" aria-hidden="true" loading="lazy"&gt;&#10; &lt;div class="tweet-card__identity"&gt;&lt;strong&gt;Derik Hammer&lt;/strong&gt;&lt;span&gt;@SQLHammer&lt;/span&gt;&lt;/div&gt;&#10; &lt;div class="tweet-card__brand" aria-label="Twitter"&gt;&#10; &lt;svg class="tweet-card__bird" width="18" height="18" viewBox="0 0 24 24" aria-hidden="true"&gt;&lt;path d="M23.95 4.57a9.8 9.8 0 0 1-2.82.77 4.93 4.93 0 0 0 2.16-2.72 9.86 9.86 0 0 1-3.12 1.19 4.92 4.92 0 0 0-8.39 4.48A13.98 13.98 0 0 1 1.64 3.16a4.92 4.92 0 0 0 1.52 6.57 4.9 4.9 0 0 1-2.23-.62v.06a4.93 4.93 0 0 0 3.95 4.83 4.93 4.93 0 0 1-2.22.08 4.93 4.93 0 0 0 4.6 3.42A9.88 9.88 0 0 1 0 19.54a13.94 13.94 0 0 0 7.55 2.21c9.05 0 14-7.5 14-14v-.64a10 10 0 0 0 2.46-2.54z"/&gt;&lt;/svg&gt;&#10; &lt;span&gt;twitter&lt;/span&gt;&#10; &lt;/div&gt;&#10; &lt;/div&gt;&#10; &lt;div class="tweet-card__text"&gt;What is the best way to move 2008 R2 SSRS reports into an existing 2012 SSRS instance? Catalog move is insufficient here. #sqlhelp&lt;/div&gt;&#10; &#10; &lt;div class="tweet-card__footer"&gt;&lt;time datetime="2016-06-29T14:47:59Z"&gt;2:47 PM · Jun 29, 2016&lt;/time&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;p&gt;This reminded me of a PowerShell script I wrote a few years back, so I&amp;rsquo;m dusting it off for this blog post. I&amp;rsquo;m far from a PowerShell Pro, but I think this will be helpful to other people&lt;/p&gt;</description></item><item><title>T-SQL Tuesday #79 - COMPRESS()ing LOB data</title><link>https://am2.co/2016/06/14/t-sql-tuesday-79/</link><pubDate>Tue, 14 Jun 2016 09:00:25 -0400</pubDate><guid>https://am2.co/2016/06/14/t-sql-tuesday-79/</guid><description>&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" width="300" height="300" /&gt;&#10;&lt;blockquote&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Michael J Swart&lt;/strong&gt; (&lt;a href="http://michaeljswart.com/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;| &lt;a href="https://twitter.com/mjswart" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). The topic: &lt;strong&gt;&lt;a href="http://michaeljswart.com/2016/06/t-sql-tuesday-079-its-2016/" target="_blank" rel="noopener"&gt;SQL Server 2016 is out!&lt;/a&gt;&lt;/strong&gt;&lt;/blockquote&gt;&#10;SQL Server 2016 is hot off the presses, and Michael challenges us to blog about it.&#10;&lt;p&gt;I&amp;rsquo;ve been using SSMS 2016 (I&amp;rsquo;m impressed!), but I haven&amp;rsquo;t spent tons of time using the server-side bits. As I type this intro, the 2016 installer is chugging along getting a fresh instance ready for me to explore so I can write about&amp;hellip;&lt;/p&gt;</description></item><item><title>Add-Equals operator</title><link>https://am2.co/2016/05/24/add-equals-operator/</link><pubDate>Tue, 24 May 2016 10:00:19 -0400</pubDate><guid>https://am2.co/2016/05/24/add-equals-operator/</guid><description>&lt;h2 id="shortcuts--tips-from-an-impatient-dba"&gt;Shortcuts &amp;amp; tips from an Impatient DBA&lt;/h2&gt;&#10;&lt;p&gt;This series of short posts will demonstrate some lesser-known features, keyboard shortcuts, and other tips that make my day as a DBA more productive. None of these are groundbreaking super-secret features–they are the little things that I do as part of my daily work that make me more efficient.&lt;/p&gt;</description></item><item><title>Microsoft sql server management studio (SSMS) shortcut for changing size of sql/result panes</title><link>https://am2.co/2016/05/16/microsoft-sql-server-management-studio-ssms-shortcut-for-changing-size-of-sql-result-panes/</link><pubDate>Mon, 16 May 2016 11:09:17 -0400</pubDate><guid>https://am2.co/2016/05/16/microsoft-sql-server-management-studio-ssms-shortcut-for-changing-size-of-sql-result-panes/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/138623/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In the good old days there was a shortcut &lt;code&gt;ctrl-B&lt;/code&gt; for changing the size of the Query &amp;amp; Result panes in the Query Analyzer sql editor. &lt;/p&gt;&#10;&lt;p&gt;In Query Analyzer, just press &lt;code&gt;ctrl-B&lt;/code&gt; and the screen splitter handle was in focus. Then repeatedly press up/down arrows until the size was right.&lt;/p&gt;</description></item><item><title>T-SQL Tuesday #78– sys.dm_db_file_space_usage</title><link>https://am2.co/2016/05/10/tsql-tuesday-78/</link><pubDate>Tue, 10 May 2016 10:00:59 -0400</pubDate><guid>https://am2.co/2016/05/10/tsql-tuesday-78/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=R0xoMhCT-7A"&gt;&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" width="300" height="300" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;blockquote&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Wendy Pastrick&lt;/strong&gt; (&lt;a href="http://wendyverse.blogspot.com/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;| &lt;a href="https://twitter.com/wendy_dance" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). The topic: &lt;a href="http://wendyverse.blogspot.com/2016/04/its-time-for-t-sql-tuesday-78-may-2016.html" target="_blank" rel="noopener"&gt;&lt;strong&gt;Learn something new and blog about it&lt;/strong&gt;&lt;/a&gt;&lt;/blockquote&gt;&#10;SQL Server 2016 is coming out next month, and it's chock full of new features that I can learn. &lt;a href="https://msdn.microsoft.com/en-us/library/dn765131.aspx" target="_blank" rel="noopener"&gt;Row-level security&lt;/a&gt; is interesting. &lt;a href="https://msdn.microsoft.com/en-us/library/mt130841.aspx" target="_blank" rel="noopener"&gt;Dynamic data masking&lt;/a&gt; sounds fun.&#10;&lt;p&gt;If you&amp;rsquo;re a regular reader of my blog, you probably know I try to approach questions from a unique angle. Instead of blogging about something cutting edge or sexy, I decided to scroll through the list of system views until I found one I didn&amp;rsquo;t recognize.&lt;/p&gt;</description></item><item><title>How to shrink a database in 4 easy steps</title><link>https://am2.co/2016/04/28/shrink-database-4-easy-steps/</link><pubDate>Thu, 28 Apr 2016 11:00:22 -0400</pubDate><guid>https://am2.co/2016/04/28/shrink-database-4-easy-steps/</guid><description>&lt;figure class="wp-caption alignright" style="max-width:238px"&gt;&lt;a href="https://www.youtube.com/watch?v=03L8u9S1vyY" rel="noopener noreferrer" target="_blank"&gt;&lt;img class="wp-image-438 size-medium" src="https://am2.co/wp-content/uploads/ShrinkyDinks-1-238x300.jpg" alt="I pity the fool who shrinks his database!" width="238" height="300" /&gt;&lt;/a&gt; I pity the fool who needs to shrink his database!&lt;/figure&gt;&#10;&lt;p&gt;It&amp;rsquo;s a really common question: &amp;ldquo;How do I shrink my database?&amp;rdquo;&#10;Luckily, there&amp;rsquo;s also a really common answer: &amp;ldquo;Don&amp;rsquo;t.&amp;rdquo;&lt;/p&gt;&#10;&lt;h3 id="but-what-if-you-really-have-to"&gt;&amp;hellip;but what if you really have to?&lt;/h3&gt;&#10;&lt;p&gt;Perhaps you just implemented &lt;a href="https://am2.co/category/data-compression/"&gt;data compression&lt;/a&gt;, and have 60% free space in your database.&#10;Perhaps you just deleted a bunch of old data, and have significant free space in your database.&#10;There are a handful of scenarios where you have free space in the database, you&amp;rsquo;ll never use it, and you need to shrink. Just don&amp;rsquo;t make a habit of it.&lt;/p&gt;</description></item><item><title>CONVERT() to float using scientific notation</title><link>https://am2.co/2016/04/20/convert-float-using-scientific-notation/</link><pubDate>Wed, 20 Apr 2016 10:57:01 -0400</pubDate><guid>https://am2.co/2016/04/20/convert-float-using-scientific-notation/</guid><description>&lt;p&gt;Someone posted to &lt;a href="https://twitter.com/search?f=tweets&amp;amp;vertical=default&amp;amp;q=%23sqlhelp" target="_blank"&gt;#sqlhelp&lt;/a&gt; on Twitter, asking the following: &amp;ldquo;Wondered if anyone could enlighten me as to why ISNUMERIC(&amp;lsquo;7d8&amp;rsquo;) returns 1?&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, &lt;code&gt;SELECT ISNUMERIC('7d8')&lt;/code&gt; returns a 1.&lt;/p&gt;&#10;&lt;h3 id="wtf-d-isnt-numeric"&gt;WTF? d isn&amp;rsquo;t numeric!&lt;/h3&gt;&#10;&lt;p&gt;OK, sure, if you say &amp;ldquo;seven-dee-eight&amp;rdquo; out loud it &lt;em&gt;sounds&lt;/em&gt; like a number, but &amp;ldquo;d&amp;rdquo; is a letter, not a number.&lt;/p&gt;</description></item><item><title>How fast queries hurt performance</title><link>https://am2.co/2016/04/15/fast-queries-hurt/</link><pubDate>Fri, 15 Apr 2016 12:36:16 -0400</pubDate><guid>https://am2.co/2016/04/15/fast-queries-hurt/</guid><description>&lt;p&gt;This week at work, I noticed CPU on one server seemed pretty high. I wasn&amp;rsquo;t familiar with this particular server, but based on the applications it supported, I was expecting the server to be under-utilized. I went over to vCenter to look at historical CPU performance, and see if high CPU was normal. When I looked at 30-day CPU usage, what I saw was alarming:&lt;/p&gt;</description></item><item><title>T-SQL Tuesday #77– My favorite SQL Server feature</title><link>https://am2.co/2016/04/12/tsql-tuesday-77/</link><pubDate>Tue, 12 Apr 2016 22:51:47 -0400</pubDate><guid>https://am2.co/2016/04/12/tsql-tuesday-77/</guid><description>&lt;img class="alignright wp-image-532 size-full" src="https://am2.co/wp-content/uploads/TSQL2SDAY-300x300.png" width="300" height="300" /&gt;&#10;&lt;blockquote&gt;It’s T-SQL Tuesday,  the blog party that SQL Server expert &lt;strong&gt;Adam Machanic&lt;/strong&gt; (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|t&lt;a href="http://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;witter&lt;/a&gt;) started. This month’s episode is hosted by &lt;strong&gt;Jens Vestergaard&lt;/strong&gt; (&lt;a href="http://t-sql.dk/" target="_blank" rel="noopener"&gt;blog &lt;/a&gt;| &lt;a href="https://twitter.com/vestergaardj" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). The topic: &lt;a href="http://t-sql.dk/?p=1492" target="_blank" rel="noopener"&gt;&lt;strong&gt;Favorite SQL Server Feature&lt;/strong&gt;&lt;/a&gt;.&lt;/blockquote&gt;&#10;When I saw this topic, I was really excited. My mind started racing through all the awesome features in SQL Server. I spend a lot of time dealing with HA and DR--so many features to choose from...but are any of them my &lt;strong&gt;favorite&lt;/strong&gt;? No, probably not. &lt;a href="https://www.mssqltips.com/sqlservertip/2445/sql-server-multi-server-administration/" target="_blank" rel="noopener"&gt;MSX&lt;/a&gt; and &lt;a href="https://msdn.microsoft.com/en-us/library/bb895144.aspx" target="_blank" rel="noopener"&gt;CMS&lt;/a&gt; have made my life so much easier, and they are incredibly cool, and I've not blogged about either of them...but...neither is my favorite.&#10;&lt;p&gt; &lt;/p&gt;</description></item><item><title>Users in SQL Server cluster</title><link>https://am2.co/2016/04/12/users-in-sql-server-cluster/</link><pubDate>Tue, 12 Apr 2016 12:17:30 -0400</pubDate><guid>https://am2.co/2016/04/12/users-in-sql-server-cluster/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/135057/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have created a 2012 WFC and SQL Server 2014 is clustered on it. The cluster works as expected but have a question on Users:&lt;/p&gt;&#10;&lt;p&gt;I added a windows domain group to the cluster as sysadmin. &lt;/p&gt;&#10;&lt;p&gt;When the user tries to log into SQL on the active server the users rights are not right. They can’t see anything. If the same user logs in from the no active server they have full admin rights, if they log in from their local machine they have the proper sysadmin rights. &lt;/p&gt;</description></item><item><title>ReportServerTempDB in AlwaysOn Availability group</title><link>https://am2.co/2016/04/11/reportservertempdb-in-alwayson-availability-group/</link><pubDate>Mon, 11 Apr 2016 16:01:57 -0400</pubDate><guid>https://am2.co/2016/04/11/reportservertempdb-in-alwayson-availability-group/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134983/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;ReportserverTempdb logfile is 6TB in size and growing and I need help. I am supporting a huge reporting server farm and the client wants reporting services to be in AlawysON Availability group(AAG) and we configured reportserver and reportserverTempDB on in three node Primary replica, synchronize Secondary replica and DR in a different location with manual synchronization.&#10;Microsoft recommends reportservertempdb to be in simple recovery mode but if you add it to AAG that is not an option. Does anyone has reportservertempdb in AAG?&#10;I would like to advise customer to take reporservertempDB out of AAG and we can just keep the copy of the reportservertempdb on each node and that should be fine.&#10;Please advise.&lt;/p&gt;</description></item><item><title>Exclude All Matching Rows</title><link>https://am2.co/2016/04/08/exclude-all-matching-rows/</link><pubDate>Fri, 08 Apr 2016 17:14:26 -0400</pubDate><guid>https://am2.co/2016/04/08/exclude-all-matching-rows/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134791/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a table that has a unique ID, name, email, and some other fields. I want to match this table against another table on email, but sometimes emails are shared. The unique ID is not shared among tables, but I will input the ID into the other table when I have identified them. Name is not unique.&lt;/p&gt;</description></item><item><title>Convert row into concatenated string with column names included</title><link>https://am2.co/2016/04/06/convert-row-into-concatenated-string-with-column-names-included/</link><pubDate>Wed, 06 Apr 2016 15:53:55 -0400</pubDate><guid>https://am2.co/2016/04/06/convert-row-into-concatenated-string-with-column-names-included/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134555/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a table that is several hundred columns wide. Is there a way to convert each row into a single concatenated string with the column title included without having to list each single column in the query? &lt;/p&gt;&#10;&lt;p&gt;I'm doing this because the columns represents fields in an event report. I'm putting them back together so a person can read the report in a logical manner.&lt;/p&gt;</description></item><item><title>SQL Server: How to export database with linked servers</title><link>https://am2.co/2016/04/04/sql-server-how-to-export-database-with-linked-servers/</link><pubDate>Mon, 04 Apr 2016 10:27:53 -0400</pubDate><guid>https://am2.co/2016/04/04/sql-server-how-to-export-database-with-linked-servers/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134279/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm a web developer and I want to export a database to work on it in my local machine.&lt;/p&gt;&#10;&lt;p&gt;I'm using &lt;code&gt;generate script with data&lt;/code&gt;. the script is generated but without the linked servers used by some Views.&lt;/p&gt;&#10;&lt;p&gt;Is their a way to generate a full script with linked servers or do I have to create it manually with &lt;code&gt;sp_addlinkedserver&lt;/code&gt;?&lt;/p&gt;</description></item><item><title>Reduce MDF file size</title><link>https://am2.co/2016/04/01/reduce-mdf-file-size/</link><pubDate>Fri, 01 Apr 2016 17:26:01 -0400</pubDate><guid>https://am2.co/2016/04/01/reduce-mdf-file-size/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134524/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am working with a 500 GB SQL Server database. I need to reduce the size of the database data file after removing a large amount (50%) of the data.&lt;/p&gt;&#10;&lt;p&gt;I tried re indexing, it's good the database has de-fragmented. But the DB size is not reduced.&lt;/p&gt;</description></item><item><title>Using DateTime Variable In Where Clause</title><link>https://am2.co/2016/03/30/using-datetime-variable-in-where-clause/</link><pubDate>Wed, 30 Mar 2016 15:22:09 -0400</pubDate><guid>https://am2.co/2016/03/30/using-datetime-variable-in-where-clause/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133840/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to pull all data where a sale date is &gt;= to a certain datetime. When I execute my query I get an error of:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10; &lt;p&gt;Msg 241, Level 16, State 1, Line 15&lt;br&gt;&#10; Conversion failed when converting date and/or time from character string.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>How to efficiently design MongoDB database for Uber-like application?</title><link>https://am2.co/2016/03/30/how-to-efficiently-design-mongodb-database-for-uber-like-application/</link><pubDate>Wed, 30 Mar 2016 14:01:04 -0400</pubDate><guid>https://am2.co/2016/03/30/how-to-efficiently-design-mongodb-database-for-uber-like-application/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133822/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm designing a MongoDB database for an Uber-like application, but since I'm new to NoSQL concept, I have several doubts.&lt;/p&gt;&#10;&lt;p&gt;I have three main collections - users, requests and messages. User can post a ride request, and if other user wants to give him a ride, accepts such a request and now text communication between those two users is started.&lt;/p&gt;</description></item><item><title>How to configure SSIS in SQL Server AlwaysOn</title><link>https://am2.co/2016/03/30/how-to-configure-ssis-in-sql-server-alwayson/</link><pubDate>Wed, 30 Mar 2016 05:40:07 -0400</pubDate><guid>https://am2.co/2016/03/30/how-to-configure-ssis-in-sql-server-alwayson/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133760/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have AlwaysOn Availability Group setup for my SQL Server. Now I would like to configure SSIS. How do I do it? Below link provides some information but since I am not DBA it's difficult to understand this article: &lt;/p&gt;</description></item><item><title>UFT to SQL Server conecction which is located at different domain</title><link>https://am2.co/2016/03/29/uft-to-sql-server-conecction-which-is-located-at-different-domain/</link><pubDate>Tue, 29 Mar 2016 16:42:56 -0400</pubDate><guid>https://am2.co/2016/03/29/uft-to-sql-server-conecction-which-is-located-at-different-domain/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133702/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need to connect to a SQL Server through UFT (Unified Functional Testing) but the problem is SQL Server is present at different domain whereas QTP (HP QuickTest Professional) is present in a different domain. &lt;/p&gt;&#10;&lt;p&gt;I am able to connect to SQL Server manually from my domain using &lt;/p&gt;</description></item><item><title>After trying to restart moved database: Unable to open the physical file "D:\Data\MYDBNAME.MDF"</title><link>https://am2.co/2016/03/29/after-trying-to-restart-moved-database-unable-to-open-the-physical-file-ddatamydbname-mdf/</link><pubDate>Tue, 29 Mar 2016 13:01:56 -0400</pubDate><guid>https://am2.co/2016/03/29/after-trying-to-restart-moved-database-unable-to-open-the-physical-file-ddatamydbname-mdf/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133663/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;So the default location for databases on our server is &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10;c:\program files\microsoft sql server\mssql11.mssqlserver\mssql\DATA&#10;&lt;/div&gt;&#10;&lt;p&gt;but due to space limitations we instead use &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10;d:\data&#10;&lt;/div&gt;&#10;&lt;p&gt;I have now since corrected the default location to be &lt;code&gt;d:\data&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;However I am unable to move a database that was created in the wrong location i.e. from &lt;code&gt;c:\...\data&lt;/code&gt; to &lt;code&gt;d:\data&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Why is the MSDB database TRUSTWORTHY?</title><link>https://am2.co/2016/03/24/why-is-the-msdb-database-trustworthy/</link><pubDate>Thu, 24 Mar 2016 20:38:35 -0400</pubDate><guid>https://am2.co/2016/03/24/why-is-the-msdb-database-trustworthy/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133325/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;The &lt;code&gt;TRUSTWORTHY&lt;/code&gt; setting can be rather dangerous if you aren't careful and except for specific circumstances the recommendation is to keep it turned off. However by default the &lt;code&gt;MSDB&lt;/code&gt; database has &lt;code&gt;TRUSTWORHTY&lt;/code&gt; set &lt;code&gt;ON&lt;/code&gt; by default. I'm curious why?&lt;/p&gt;</description></item><item><title>UnShrunk SQL Server database restore which is larger than available disk space</title><link>https://am2.co/2016/03/22/unshrunk-sql-server-database-restore-which-is-larger-than-available-disk-space/</link><pubDate>Tue, 22 Mar 2016 19:17:25 -0400</pubDate><guid>https://am2.co/2016/03/22/unshrunk-sql-server-database-restore-which-is-larger-than-available-disk-space/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133819/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I cannot restore a Microsoft SQL Server database due to lack of hard drive space. The original database was 1.6TB and approximately &lt;strong&gt;1.4TB&lt;/strong&gt; was deleted from it and a backup was taken without shrinking the database.&lt;/p&gt;&#10;&lt;p&gt;The backup file is only 168GB and was sent to me on a hard drive through a courier. When I try to restore the 168GB backup file it tries to create the original 1.6TB &lt;code&gt;.mdf&lt;/code&gt; data file and errors because all my available servers have less than 1TB of available disk space.&lt;/p&gt;</description></item><item><title>What's the deal with transactions in a stored procedure called by an SSRS report?</title><link>https://am2.co/2016/03/01/whats-the-deal-with-transactions-in-a-stored-procedure-called-by-an-ssrs-report/</link><pubDate>Tue, 01 Mar 2016 23:00:41 -0500</pubDate><guid>https://am2.co/2016/03/01/whats-the-deal-with-transactions-in-a-stored-procedure-called-by-an-ssrs-report/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/130948/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Consider the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;PROCEDURE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dbo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usp_trantest&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@@&lt;/span&gt;&lt;span class="n"&gt;TRANCOUNT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;trancount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;GO&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When I call &lt;code&gt;usp_trantest&lt;/code&gt; manually from within SSMS, the trancount is 0. If I run an SSRS report that contains a dataset that queries the same stored procedure, the trancount is logged as 1.&lt;/p&gt;</description></item><item><title>Decoding sql_handle</title><link>https://am2.co/2016/02/29/decoding_sql_handle/</link><pubDate>Mon, 29 Feb 2016 10:05:54 -0500</pubDate><guid>https://am2.co/2016/02/29/decoding_sql_handle/</guid><description>&lt;p&gt;If you&amp;rsquo;ve ever looked at sys.sysprocesses or sys.dm_exec_requests (or a number of other DMVs), you&amp;rsquo;ve noticed there is a column called &amp;ldquo;sql_handle&amp;rdquo; that contains some binary gobbledygook. Books Online gives the (un)helpful definition as &amp;ldquo;Hash map of the SQL text of the request.&amp;rdquo;&lt;/p&gt;&#10;&lt;h3 id="sp_whoisactive"&gt;sp_WhoIsActive&lt;/h3&gt;&#10;&lt;p&gt;In the context of currently-running processes, most people decode sql_handle with Adam Machanic&amp;rsquo;s (&lt;a href="http://dataeducation.com/blog/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/adammachanic" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;) &lt;a href="http://whoisactive.com/" target="_blank" rel="noopener"&gt;sp_WhoIsActive&lt;/a&gt;. It&amp;rsquo;s really easy &amp;amp; straightforward&amp;ndash;if you&amp;rsquo;re not familiar with Adam&amp;rsquo;s utility, download it and check it out. My friend Mike Kane (&lt;a href="http://www.michaelkane.me/" target="_blank" rel="noopener"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/tcp1433" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;) has an &lt;a href="http://www.michaelkane.me/2016/03/how-i-use-sp_whoisactive/" target="_blank" rel="noopener"&gt;interesting post&lt;/a&gt; on parameter combinations he regularly uses when using sp_WhoIsActive.&lt;/p&gt;</description></item><item><title>Data Compression: How page compression works</title><link>https://am2.co/2016/02/22/data-compression-how-page-works/</link><pubDate>Mon, 22 Feb 2016 10:00:59 -0500</pubDate><guid>https://am2.co/2016/02/22/data-compression-how-page-works/</guid><description>&lt;p&gt;SQL Server supports two kinds of data compression on rowstore data. Columnstore compression is for a different day. You can compress heaps, clustered indexes (on both tables and views), and nonclustered indexes (on both tables and views).&lt;/p&gt;&#10;&lt;h3 id="compression-requirements"&gt;Compression requirements&lt;/h3&gt;&#10;&lt;p&gt;Data compression is available in SQL Server 2008 &amp;amp; newer. It was introduced as an Enterprise Edition feature&amp;ndash;if you were using Standard Edition or Express, then you were out of luck. Starting with SQL Server 2016 SP1 (thus all currently-supported versions), data compression is available across all Editions. There are &lt;a href="https://am2.co/2015/12/29/data-compression-costs-benefits/"&gt;benefits &amp;amp; costs to using data compression&lt;/a&gt;&amp;ndash;as with anything, make sure you understand it before you implement it.&lt;/p&gt;</description></item><item><title>xp_sqlagent_enum_jobs alternative</title><link>https://am2.co/2016/02/18/xp_sqlagent_enum_jobs_alt/</link><pubDate>Thu, 18 Feb 2016 10:00:21 -0500</pubDate><guid>https://am2.co/2016/02/18/xp_sqlagent_enum_jobs_alt/</guid><description>&lt;h3&gt;What's &lt;code&gt;xp_sqlagent_enum_jobs&lt;/code&gt;?&lt;/h3&gt;&#10;If you landed on this post, I'm guessing you know the answer to this, so I'll be quick. `xp_sqlagent_enum_jobs` is an undocumented (and thus, unsupported) extended procedure that gives information on whether a job is currently running, when it last ran, when it runs next, etc.&#10;&lt;p&gt;The supported alternative is to use &lt;code&gt;sp_help_job&lt;/code&gt; (which calls &lt;code&gt;xp_sqlagent_enum_jobs&lt;/code&gt;), but &lt;code&gt;sp_help_job&lt;/code&gt; is difficult to use in automation because trying to do &lt;code&gt;INSERT #temp EXEC sp_help_job;&lt;/code&gt; will result in an error due to nested &lt;code&gt;INSERT...EXEC&lt;/code&gt; statements (Error 8164: &amp;ldquo;An INSERT EXEC statement cannot be nested.&amp;rdquo;). As a result, people often turn to calling the unsupported xp directly.&lt;/p&gt;</description></item><item><title>Data Compression: How row compression works</title><link>https://am2.co/2016/02/15/data-compression-how-row-works/</link><pubDate>Mon, 15 Feb 2016 10:07:29 -0500</pubDate><guid>https://am2.co/2016/02/15/data-compression-how-row-works/</guid><description>&lt;p&gt;SQL Server supports two kinds of data compression on rowstore data. Columnstore compression is for a different day. You can compress heaps, clustered indexes (on both tables and views), and nonclustered indexes (on both tables and views).&lt;/p&gt;&#10;&lt;h3 id="compression-requirements"&gt;Compression requirements&lt;/h3&gt;&#10;&lt;p&gt;Data compression is available in SQL Server 2008 &amp;amp; newer. It is an Enterprise Edition feature&amp;ndash;if you&amp;rsquo;re using Standard Edition or Express, then you&amp;rsquo;re out of luck. There are &lt;a href="https://am2.co/2015/12/29/data-compression-costs-benefits/"&gt;benefits &amp;amp; costs to using data compression&lt;/a&gt;&amp;ndash;as with anything, make sure you understand it before you implement it.&lt;/p&gt;</description></item><item><title>Speaking at #SqlSatChi - SQL Saturday #484 in Chicago</title><link>https://am2.co/2016/01/23/speaking-at-sqlsatchi-sql-saturday-484-in-chicago/</link><pubDate>Sat, 23 Jan 2016 09:41:45 -0500</pubDate><guid>https://am2.co/2016/01/23/speaking-at-sqlsatchi-sql-saturday-484-in-chicago/</guid><description>&lt;p&gt;I&amp;rsquo;m really excited to be speaking in Chicago this year. I&amp;rsquo;m going to be giving my &amp;ldquo;Shortcuts From an Impatient DBA&amp;rdquo; session. I love this presentation, and I&amp;rsquo;m excited to share it in Chicago.&lt;/p&gt;&#10;&lt;h3 id="howd-you-do-that"&gt;How&amp;rsquo;d you do that?!?&lt;/h3&gt;&#10;&lt;p&gt;This presentation is a series of keyboard shortcuts, lesser-known SSMS features, code tricks, Windows tips, etc. Most of these are tips I picked up by watching other people and asking &amp;ldquo;How&amp;rsquo;d you do that?&amp;rdquo; Those are some of the most powerful learning moments we have&amp;ndash;when we see something cool and learn to do it for ourselves. I&amp;rsquo;ll say it again: &lt;strong&gt;I love this presentation&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Windows cluster failed over, but SQL instances didn't move</title><link>https://am2.co/2016/01/04/windows-cluster-failed-over-but-sql-instances-didnt-move/</link><pubDate>Mon, 04 Jan 2016 13:48:24 -0500</pubDate><guid>https://am2.co/2016/01/04/windows-cluster-failed-over-but-sql-instances-didnt-move/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134093/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I recently inherited a SQL Cluster (2008R2) which for the most part behaves itself impeccably. &lt;/p&gt;&#10;&lt;p&gt;The windows cluster is made up of two nodes running Active/Passive, Node1 and Node2 are dedicated blades in two different data centers. There are 3 SQL instances all running on Node1. Quorum is established by a File Share Witness and we have a heartbeat between the two nodes.&lt;/p&gt;</description></item><item><title>Data Compression: Costs &amp; benefits</title><link>https://am2.co/2015/12/29/data-compression-costs-benefits/</link><pubDate>Tue, 29 Dec 2015 15:00:56 -0500</pubDate><guid>https://am2.co/2015/12/29/data-compression-costs-benefits/</guid><description>&lt;p&gt;SQL Server supports two kinds of data compression on rowstore data. Columnstore compression is for a different day. You can compress heaps, clustered indexes (on both tables and views), and nonclustered indexes (on both tables and views).&lt;/p&gt;&#10;&lt;h3 id="compression-requirements"&gt;Compression requirements&lt;/h3&gt;&#10;&lt;p&gt;Data compression is available in SQL Server 2008 &amp;amp; newer. It is an Enterprise Edition feature&amp;ndash;if you&amp;rsquo;re using Standard Edition or Express, then you&amp;rsquo;re out of luck.&lt;/p&gt;</description></item><item><title>sp_autostats: object-level auto update statistics</title><link>https://am2.co/2015/12/15/sp_autostats/</link><pubDate>Tue, 15 Dec 2015 11:00:00 -0500</pubDate><guid>https://am2.co/2015/12/15/sp_autostats/</guid><description>&lt;p&gt;In SQL Server, auto-update statistics is a database level setting. It&amp;rsquo;s right  there:&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://am2.co/wp-content/uploads/2015/12/sp_autostats1.png" rel="attachment wp-att-249"&gt;&lt;img class="alignnone wp-image-249 size-full" src="https://am2.co/wp-content/uploads/2015/12/sp_autostats1.png" alt="Auto Update Statistics" width="901" height="200" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m not going to say whether I think Auto Update Statistics should be on or off. Instead, I&amp;rsquo;m going to argue that there are definitely scenarios when you want to have this on AND there are scenarios where you want it turned off. Can you really have this both ways? Absolutely.&lt;/p&gt;</description></item><item><title>DROP TABLE Bug on Filestream Garbage Collection</title><link>https://am2.co/2015/12/08/bug-in-filestream-gc-ag/</link><pubDate>Tue, 08 Dec 2015 15:36:05 -0500</pubDate><guid>https://am2.co/2015/12/08/bug-in-filestream-gc-ag/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=-IaeTAb0rdk"&gt;&lt;img src="https://am2.co/wp-content/uploads/trash-truck-james-day-ECyvZuZeLGc-unsplash-768x1024.jpg" alt="" width="384" height="512" class="alignright size-large wp-image-3225" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;FILESTREAM is not a particularly popular feature of SQL Server&amp;ndash;if you&amp;rsquo;re using it, you are in the minority. If you have a database with filestream in an Availability Group, then you&amp;rsquo;re REALLY in the minority. At my 9-5, this is being done, and it&amp;rsquo;s apparent that this combination of features isn&amp;rsquo;t a robust combination.&lt;/p&gt;</description></item><item><title>#sqlcares, #sqlwish, and #sqlfamily</title><link>https://am2.co/2015/11/19/sqlcares-sqlwish-and-sqlfamily/</link><pubDate>Thu, 19 Nov 2015 11:00:34 -0500</pubDate><guid>https://am2.co/2015/11/19/sqlcares-sqlwish-and-sqlfamily/</guid><description>&lt;p&gt;I&amp;rsquo;ve been using SQL Server for a dozen years now, but I&amp;rsquo;ve only been starting to make friendships and build relationships within the SQL Server community in the last couple of years. More importantly, it has only been in the last year that I would say I have really gotten involved to the point where I feel I am part of the SQL Server &lt;strong&gt;family&lt;/strong&gt;. This post isn&amp;rsquo;t about my journey, but rather it is about the incredible family of which I have found myself a member.&lt;/p&gt;</description></item><item><title>RECONFIGURE—When to use WITH OVERRIDE?</title><link>https://am2.co/2015/11/17/reconfigure-when-to-use-with-override/</link><pubDate>Tue, 17 Nov 2015 11:00:19 -0500</pubDate><guid>https://am2.co/2015/11/17/reconfigure-when-to-use-with-override/</guid><description>&lt;p&gt;When you&amp;rsquo;re using sp_configure to change a system configuration, you have to run a RECONFIGURE to finalize your change. You even get the helpful output that reminds you to run RECONFIGURE:&lt;/p&gt;&#10;&lt;pre&gt;Configuration option 'max degree of parallelism' changed from 0 to 1. &#10;Run the RECONFIGURE statement to install.&lt;/pre&gt;&#10;&lt;p&gt;There are many places online with code samples (Books Online, blog posts, vendor documentation, etc) that actually use the additional &amp;ldquo;RECONFIGURE WITH OVERRIDE&amp;rdquo; syntax:&#10;&lt;a href="http://blog.sqlauthority.com/2007/10/20/sql-server-set-server-level-fillfactor-using-t-sql-script/" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&#10;&lt;a href="https://msdn.microsoft.com/en-us/library/ms189094.aspx" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&#10;&lt;a href="http://www.mytechmantra.com/LearnSQLServer/How-to-Enable-and-Disable-XP_CMDSHELL-using-SP_CONFIGURE/" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&#10;There are even posts that switch between including &amp;ldquo;WITH OVERRIDE&amp;rdquo; and not including it&#10;&lt;a href="http://www.snapdba.com/2013/04/enabling-and-configuring-database-mail-in-sql-server-using-t-sql/" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Speaking at SQL Saturday #465 in Providence, RI</title><link>https://am2.co/2015/11/10/speaking-at-sql-saturday-465-in-providence-ri/</link><pubDate>Tue, 10 Nov 2015 11:00:55 -0500</pubDate><guid>https://am2.co/2015/11/10/speaking-at-sql-saturday-465-in-providence-ri/</guid><description>&lt;p&gt;On December 5, I’m speaking at QL Saturday #465 in Providence, RI. My session is called “&lt;a href="https://web.archive.org/web/20151206165625/http://www.sqlsaturday.com/465/sessions/details.aspx?sid=40676" target="_blank" rel="noopener noreferrer"&gt;Shortcuts from an Impatient DBA&lt;/a&gt;.&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;This is an expanded version of my lightning talk from the New England SQL Server User Group earlier this year. It went over so well, I decided to expand it into a full-length session.&lt;/p&gt;</description></item><item><title>Speaking at SQL Saturday #470 in DC</title><link>https://am2.co/2015/11/09/speaking-at-sql-saturday-470-in-dc/</link><pubDate>Mon, 09 Nov 2015 11:00:43 -0500</pubDate><guid>https://am2.co/2015/11/09/speaking-at-sql-saturday-470-in-dc/</guid><description>&lt;p&gt;On December 5, I&amp;rsquo;m speaking at &lt;a href="https://web.archive.org/web/20171111203945/http://www.sqlsaturday.com/470/eventhome.aspx" target="_blank" rel="noopener noreferrer"&gt;SQL Saturday #470&lt;/a&gt; in Washington DC. My session is called &amp;ldquo;&lt;a href="https://web.archive.org/web/20151108111257/http://www.sqlsaturday.com/470/Sessions/Details.aspx?sid=41133" target="_blank" rel="noopener noreferrer"&gt;Wheaton&amp;rsquo;s Law for Technology Pros&lt;/a&gt;&amp;rdquo; and is based on my post &amp;ldquo;&lt;a href="https://am2.co/2015/07/14/watch-your-step-dont-become-a-dba-hole/"&gt;Watch your step! Don&amp;rsquo;t become a DBA-hole&lt;/a&gt;.&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt; &lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m really looking forward to it for lots of reasons, but in particular it&amp;rsquo;s my first SQL Saturday session. Yea, sure, I helped organize SQL Saturday Boston BI this year, so it&amp;rsquo;s not my first rodeo&amp;ndash;but it&amp;rsquo;s my first &lt;em&gt;official &lt;/em&gt;time speaking at a SQL Saturday. Also exciting? My session is not at the same time as Brent Ozar&amp;rsquo;s (&lt;a href="http://www.brentozar.com/archive/author/brento/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt;|&lt;a href="https://twitter.com/BrentO" target="_blank" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;)&amp;ndash;I don&amp;rsquo;t have to compete with him. Score.&lt;/p&gt;</description></item><item><title>Thank you #sqlsatbostonbi 2015</title><link>https://am2.co/2015/10/18/thank-you-sqlsatbostonbi-2015/</link><pubDate>Sun, 18 Oct 2015 10:16:31 -0400</pubDate><guid>https://am2.co/2015/10/18/thank-you-sqlsatbostonbi-2015/</guid><description>&lt;p&gt;Yesterday was &lt;a href="https://web.archive.org/web/20151127183438/http://www.sqlsaturday.com/437/EventHome.aspx" target="_blank" rel="noopener noreferrer"&gt;SQL Saturday #437&lt;/a&gt; or as we call it, SQL Saturday Boston BI Edition. It was my first time helping to organize a SQL Saturday (or any event like this). It was an honor to be asked to join the organizing team, knowing that they already put on some impressive events.&lt;a href="https://am2.co/wp-content/uploads/2015/10/wpid-wp-1445170180531.jpg"&gt;&lt;img class="alignright wp-image-151" src="https://am2.co/wp-content/uploads/2015/10/wpid-wp-1445170180531-169x300.jpg" alt="SQL_Sat_437_Badge.jpg" width="281" height="500" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>How to pass SSRS params into a URL</title><link>https://am2.co/2015/10/10/how-to-pass-ssrs-params-into-a-url/</link><pubDate>Sat, 10 Oct 2015 14:39:36 -0400</pubDate><guid>https://am2.co/2015/10/10/how-to-pass-ssrs-params-into-a-url/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/120613/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have Native SSRS configured on a 2012 instance (11.0.2100). I have two reports with images that act as buttons to toggle between the chart report and the detail report. I want to configure the action URLs to dynamically pass in parameters when switching between the reports, so that the defaults (derived from a query) are not used when switching views, the manually inputted params would persist.&lt;/p&gt;</description></item><item><title>Dumplings, Databases and Corporate Espionage</title><link>https://am2.co/2015/10/08/dumplings-databases-and-corporate-espionage/</link><pubDate>Thu, 08 Oct 2015 23:07:22 -0400</pubDate><guid>https://am2.co/2015/10/08/dumplings-databases-and-corporate-espionage/</guid><description>&lt;p&gt;&lt;em&gt;This blog post takes a tangent from my usual technology-specific ramblings, but I&amp;rsquo;ll make the connection eventually. Just bear with me.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="dumplings"&gt;Dumplings&lt;/h2&gt;&#10;&lt;figure class="wp-caption alignright" style="max-width:350px"&gt;&lt;a href="https://am2.co/wp-content/uploads/2015/10/10554211_1582378982040239_1816800296_n1.jpg"&gt;&lt;img class="wp-image-139" src="https://am2.co/wp-content/uploads/2015/10/10554211_1582378982040239_1816800296_n1.jpg" alt="Dan dan mien, mango bubble tea, and petite chicken dumplings in Sichuan sauce" width="350" height="350" /&gt;&lt;/a&gt; Dan dan mien, mango bubble tea, and petite chicken dumplings in Sichuan sauce&lt;/figure&gt;&#10;&lt;p&gt;Today, I was craving some mapo tofu, so I went to one of my favorite lunch joints, Dumpling Daughter (&lt;a href="http://www.dumplingdaughter.com/" target="_blank" rel="noopener"&gt;website&lt;/a&gt;|&lt;a href="https://twitter.com/ddaughterboston" target="_blank" rel="noopener"&gt;twitter&lt;/a&gt;). As I walked in, I realized there was a news crew filming. When I asked Nadia, the owner, about her visitors, she asked if I&amp;rsquo;d seen the Boston Globe yet&amp;ndash;and told me to check it out. I hadn&amp;rsquo;t, so I ordered my mapo tofu, and scurried off to look up &lt;a href="https://www.bostonglobe.com/metro/2015/10/07/federal-lawsuit-accuses-dumpling-restaurant-being-nearly-identical-copy-weston-eatery/YLDDSxs0RoudSLcle74TqO/story.html" target="_blank" rel="noopener"&gt;the Globe story&lt;/a&gt; which was easy to find because it was on the main page, above the fold.&lt;/p&gt;</description></item><item><title>Really Long Descriptions on SQL Agent Jobs</title><link>https://am2.co/2015/09/25/really-long-descriptions-on-sql-agent-jobs/</link><pubDate>Fri, 25 Sep 2015 14:38:00 -0400</pubDate><guid>https://am2.co/2015/09/25/really-long-descriptions-on-sql-agent-jobs/</guid><description>&lt;h3 id="warning-silent-truncation-ahead"&gt;WARNING: Silent truncation ahead&lt;/h3&gt;&#10;&lt;p&gt;Have you ever tried to enter a really long description on a SQL Agent job?&lt;/p&gt;&#10;&lt;p&gt;Maybe you were trying to put some sort of warning to people who might be trying to edit the job, or triage info for when the job fails. (Ok, so this sort of documentation should be on your wiki, not in a job description&amp;hellip; but stuff happens)&lt;/p&gt;</description></item><item><title>Planning for an outage: Phone numbers</title><link>https://am2.co/2015/09/15/who-ya-gonna-call/</link><pubDate>Tue, 15 Sep 2015 13:29:00 -0400</pubDate><guid>https://am2.co/2015/09/15/who-ya-gonna-call/</guid><description>&lt;h2 id="who-ya-gonna-call"&gt;Who ya gonna call?&lt;/h2&gt;&#10;&lt;blockquote&gt;&lt;i&gt;If there's somethin' strange in your neighborhood&#10;Who ya gonna call?&#10;If it's something weird and it won't look good&#10;Who ya gonna call?&lt;/i&gt;&lt;/blockquote&gt;&#10;&amp;nbsp;&#10;&lt;div style="clear: both; text-align: center;"&gt;&lt;a style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;" href="https://www.youtube.com/watch?v=vntAEVjPBzQ"&gt;&lt;img class="alignnone" src="https://am2.co/wp-content/uploads/2015/09/ghostbustercar-300x213.jpg" width="320" height="227" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&#10;This summer, they've been taping the &lt;a href="http://www.imdb.com/title/tt1289401/" target="_blank"&gt;new Ghostbusters movie&lt;/a&gt; in Boston. It's pretty cool to see the Ghostbusters car rolling through the city.&#10;&lt;p&gt;Unfortunately, the Ghostbusters aren&amp;rsquo;t the right person to call when something goes boom in your data center. I&amp;rsquo;m not saying I haven&amp;rsquo;t used ghosts and gremlins as part of a root cause analysis before&amp;ndash;but even Dan Aykroyd and Bill Murray can&amp;rsquo;t help you when there&amp;rsquo;s a storage or network issue. I&amp;rsquo;m skeptical that Kristen Wiig will be much better.&lt;/p&gt;</description></item><item><title>Thanks for being awesome NE SQL!</title><link>https://am2.co/2015/09/10/thanks-for-being-awesome-ne-sql/</link><pubDate>Thu, 10 Sep 2015 01:47:00 -0400</pubDate><guid>https://am2.co/2015/09/10/thanks-for-being-awesome-ne-sql/</guid><description>&lt;div dir="ltr"&gt;This evening, I did my first presentation at a user group at my local user group. Sure, it was just a lightning talk, but the &lt;a href="http://www.meetup.com/NESQLUG/"&gt;New England SQL Server user group&lt;/a&gt; is a tough crowd. People ask tough questions. Nobody is timid about interrupting you to ask their question. My friends were there--&lt;i&gt;and my friends and I like to heckle each other&lt;/i&gt;. Oh, and mostly everyone was there to see Grant Fritchey (&lt;a href="https://twitter.com/GFritchey"&gt;twitter&lt;/a&gt;|&lt;a href="http://www.scarydba.com/"&gt;blog&lt;/a&gt;), and my opening lightning talk was standing in their way.&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;Those same things that make the NE SQL group intimidating also make it a really exciting, awesome group. I love that my local user group is large, active, smart, and eager to learn.&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;My talk went great and I got a lot of fantastic and positive feedback from people. I even managed to teach Grant something (actually, he said he learned at least two things)--considering all the things I've learned from him, I consider that a tremendous accomplishment.&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;If you were there and want the slides (or just couldn't make it in), you can download the slides &lt;a href="https://am2.co/wp-content/uploads/2015/11/20150909_Shortcuts.pptx" target="_blank"&gt;here&lt;/a&gt;.&lt;/div&gt;&#10;&lt;div dir="ltr"&gt;Thanks for being awesome, NE SQL buddies. See you again soon!&lt;/div&gt;</description></item><item><title>Will Transaction Log backup to Nul break Always On Availability Group configuration?</title><link>https://am2.co/2015/08/31/will-transaction-log-backup-to-nul-break-always-on-availability-group-configuration/</link><pubDate>Mon, 31 Aug 2015 23:08:35 -0400</pubDate><guid>https://am2.co/2015/08/31/will-transaction-log-backup-to-nul-break-always-on-availability-group-configuration/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/32321245/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Imagine we have two nodes participating in SQL 2012 AO. This is a test instance. During one of the index rebuild operation the log was grown up really big (250 GB). We are unable to back it up due to space constraint. What if we backup the Tlog to Nul (just to shrink it down) – will that break Always On?&lt;/p&gt;</description></item><item><title>Using SQL Agent MSX for Availability Groups</title><link>https://am2.co/2015/07/07/using-sql-agent-msx-for-availability-groups/</link><pubDate>Tue, 07 Jul 2015 00:22:00 -0400</pubDate><guid>https://am2.co/2015/07/07/using-sql-agent-msx-for-availability-groups/</guid><description>&lt;img src="https://am2.co/wp-content/uploads/13195035-887b-4719-bd2d-63e7ac4d8f88-large11.jpg" alt="" width="450" height="316" class="alignright size-full wp-image-564" /&gt;&#10;Availability Groups (AGs) are all the rage these days. Every SQL Saturday, every local Users Group, bloggers and DBAs everywhere are all talking about how cool they are. There's a lot of talk about how AGs provide a compelling alternative to Failover Cluster Instances (FCIs). The cost (nothing is free, of course) is that with AGs, you have non-contained objects that you need to manually keep in sync between nodes.&#10;&lt;p&gt;A lot has been said and blogged about syncing non-contained objects. &lt;a href="https://www.sqlskills.com/blogs/jonathan/synchronize-availability-group-logins-and-jobs/" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;. &lt;a href="http://sqlmag.com/blog/alwayson-availability-groups-and-sql-server-jobs-part-4-synchronizing-server-level-details" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;. &lt;a href="http://www.brentozar.com/archive/2014/11/change-alwayson-availability-groups/" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;. &lt;a href="https://sql2012alwaysonlogin.codeplex.com/" target="_blank" rel="noopener noreferrer"&gt;Here&lt;/a&gt;. And plenty of other places.&lt;/p&gt;</description></item><item><title>How to find the SQL Server Service Account</title><link>https://am2.co/2015/06/18/how-to-find-the-sql-server-service-account/</link><pubDate>Thu, 18 Jun 2015 19:24:00 -0400</pubDate><guid>https://am2.co/2015/06/18/how-to-find-the-sql-server-service-account/</guid><description>&lt;h3 id="what-is-the-service-account-running-your-instance-of-sql-server"&gt;What is the service account running your instance of SQL Server?&lt;/h3&gt;&#10;&lt;p&gt;A lot of DBAs probably know right off the top of their head&amp;ndash;maybe because they&amp;rsquo;re using the same account for every instance. Have you ever had to audit every service account on every instance? If you&amp;rsquo;ve never done an audit, there&amp;rsquo;s a good chance a surprise might be lurking for you.&lt;/p&gt;</description></item><item><title>Big security loophole with SQL Logins</title><link>https://am2.co/2015/04/30/big-security-loophole-with-sql-logins/</link><pubDate>Thu, 30 Apr 2015 16:46:00 -0400</pubDate><guid>https://am2.co/2015/04/30/big-security-loophole-with-sql-logins/</guid><description>&lt;p&gt;Aaron Bertrand (&lt;a href="https://twitter.com/AaronBertrand" target="_blank"&gt;twitter&lt;/a&gt;|&lt;a href="http://sqlperformance.com/author/abertrand" target="_blank"&gt;blog&lt;/a&gt;) recently blogged asking for help to fix a big security loophole. I read the post then, but it was only this morning that I finally got around to REALLY looking at it, thinking about it, and testing it out for myself.&lt;br /&gt;&lt;br /&gt;Aaron can do a much better job at describing the issue than I can, so I urge you to read &lt;a href="http://blogs.sqlsentry.com/aaronbertrand/please-help-me-fix-a-big-security-loophole/" target="_blank"&gt;his blog post on the topic&lt;/a&gt;, or &lt;a href="http://dba.stackexchange.com/questions/99262/does-sys-sql-logins-is-policy-checked-mean-that-the-policy-has-been-checked" target="_blank"&gt;his Stack Exchange answer on the topic&lt;/a&gt;. Then, go up-vote &lt;a href="https://connect.microsoft.com/SQLServer/Feedback/Details/1250342" target="_blank"&gt;the Connect item he filed&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I&amp;rsquo;ll do my best to give a quick summary of the issue here, if you don&amp;rsquo;t want to read Aaron&amp;rsquo;s full version:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://msdn.microsoft.com/en-us/library/ms174355.aspxhttps://msdn.microsoft.com/en-us/library/ms174355.aspx" target="_blank"&gt;Microsoft&amp;rsquo;s documentation&lt;/a&gt; explains that sys.logins.is_policy_checked means &amp;ldquo;Password policy is checked.&amp;rdquo; Bill Clinton was right, &amp;ldquo;It depends upon what the meaning of the word &amp;lsquo;is&amp;rsquo; is.&amp;quot;&lt;br /&gt;This use of &amp;ldquo;is&amp;rdquo; in this terse definition &lt;b&gt;could&lt;/b&gt; have two meanings:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;As a descriptor of what has happened: &amp;ldquo;The password policy &lt;b&gt;&lt;i&gt;&lt;u&gt;has been&lt;/u&gt;&lt;/i&gt;&lt;/b&gt; checked for this login.&amp;quot;&lt;/li&gt;&lt;li&gt;As an instruction of what SQL Server should do in the future: &amp;ldquo;The password policy &lt;b&gt;&lt;i&gt;&lt;u&gt;will be&lt;/u&gt;&lt;/i&gt;&lt;/b&gt; checked for this login.&amp;quot;&lt;br /&gt;&lt;br /&gt;(If you aren&amp;rsquo;t already hung-up thinking about Bill Clinton, I probably just gave you a flashback to a grammar school teacher grilling you on conjugations of the verb &amp;ldquo;to be.&amp;rdquo;)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;As it turns out, the correct meaning of this column is actually #2: &amp;ldquo;The password policy &lt;b&gt;&lt;i&gt;&lt;u&gt;will be&lt;/u&gt;&lt;/i&gt;&lt;/b&gt; checked for this login.&amp;rdquo;  Most people (myself included) wrongly expect this column to have the other meaning.&lt;br /&gt;&lt;br /&gt;Further, there is no DMV that describes #1: &amp;ldquo;The password policy &lt;b&gt;&lt;i&gt;&lt;u&gt;has been&lt;/u&gt;&lt;/i&gt;&lt;/b&gt; checked for this login.&amp;rdquo;  If an auditor asks you to prove that all SQL logins meet your password policy, there is no way to prove that.&lt;br /&gt;&lt;br /&gt;Yes, I can use processes to manage my own environment to a point where I am confident that the passwords are strong. However, if I were an auditor, I would demand proof the DBA wasn&amp;rsquo;t skirting the rules by altering the flag before an audit (and flipping it back later).&lt;br /&gt;&lt;br /&gt;So, I join in Aaron&amp;rsquo;s call-to-action. Go up-vote &lt;a href="https://connect.microsoft.com/SQLServer/Feedback/Details/1250342" target="_blank"&gt;the Connect item&lt;/a&gt; and get this security loophole fixed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Converting delimited values to a table (efficiently?)</title><link>https://am2.co/2015/04/21/converting-delimited-values-to-a-table-efficiently/</link><pubDate>Tue, 21 Apr 2015 15:33:00 -0400</pubDate><guid>https://am2.co/2015/04/21/converting-delimited-values-to-a-table-efficiently/</guid><description>&lt;p&gt;This is a pretty common problem. I think it&amp;rsquo;s a question every developer has asked at one time or another: &amp;ldquo;I want to pass in a comma-separated list of values, then convert it into a table.&amp;quot;&lt;br /&gt;&lt;br /&gt;Every company I&amp;rsquo;ve ever worked for has had a function that does this. Everyone does it differently. It&amp;rsquo;s never efficient. I&amp;rsquo;ve seen it done in CLR, I&amp;rsquo;ve seen it done as a multi-statement table-valued user-defined function (which we all know is the devil&amp;rsquo;s work). The CLR works, but it&amp;rsquo;s a black-box to the average DBA or SQL developer. The multi-statement TVF performs terribly, but has never been used heavily enough to make it to the top of my tuning list. &lt;br /&gt;&lt;br /&gt;This morning, I saw Pinal Dave (&lt;a href="https://twitter.com/pinaldave" target="_blank" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;|&lt;a href="http://blog.sqlauthority.com/" target="_blank" rel="noopener noreferrer"&gt;blog&lt;/a&gt;) &lt;a href="http://blog.sqlauthority.com/2015/04/21/sql-server-split-comma-separated-list-without-using-a-function/" target="_blank" rel="noopener noreferrer"&gt;post on his blog&lt;/a&gt; about this topic, and he used a really elegant XML-based solution. It&amp;rsquo;s one of those solutions that&amp;rsquo;s so simple, it&amp;rsquo;s incredibly hard.&lt;br /&gt;&lt;br /&gt;When I got to my desk this morning, I immediately wrapped Pinal&amp;rsquo;s code into a function that was backwards compatible to a multi-statement TVF version and performance tested them head-to-head.&lt;br /&gt;&lt;br /&gt;Here&amp;rsquo;s my function definition:&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Error 3203 restoring SQL Server backup: The data is invalid</title><link>https://am2.co/2015/04/17/error-3203-restoring-sql-server-backup-the-data-is-invalid/</link><pubDate>Fri, 17 Apr 2015 14:26:17 -0400</pubDate><guid>https://am2.co/2015/04/17/error-3203-restoring-sql-server-backup-the-data-is-invalid/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/98153/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to restore a .bak file (backup taken on SQL Server 2008 R2, compatibility level 100). I am restoring the backup on SQL Server 2012 edition. I get the below error. Unfortunately the original DB from where the DB was backed up is no longer available. I am new on this project. I was given the bak file on a thumb drive.&lt;/p&gt;</description></item><item><title>sp_executesql with output parameters</title><link>https://am2.co/2015/01/22/sp_executesql-with-output-parameters/</link><pubDate>Thu, 22 Jan 2015 20:05:00 -0500</pubDate><guid>https://am2.co/2015/01/22/sp_executesql-with-output-parameters/</guid><description>&lt;p&gt;One of my coworkers asked me about output parameters from dynamic SQL today. I pointed him at sp_executesql, which allows for passing parameters into or out of dynamic SQL. The syntax can be confusing at first blush (especially for a new DBA or developer), but it&amp;rsquo;s really pretty straightforward, easy, and useful.&lt;/p&gt;</description></item><item><title>Formatting HTML emails in SQL</title><link>https://am2.co/2014/11/26/formatting-html-emails-in-sql/</link><pubDate>Wed, 26 Nov 2014 15:34:00 -0500</pubDate><guid>https://am2.co/2014/11/26/formatting-html-emails-in-sql/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=RPoBE-E8VOc"&gt;&lt;img class="alignright wp-image-1224 size-mh-magazine-lite-content" src="https://am2.co/wp-content/uploads/nick-karvounis-381259-678x381.jpg" alt="" width="678" height="381" /&gt;&lt;/a&gt;When I am writing monitoring/alerting stored procedures for my SQL Servers, its important to have those alerts be well-formatted. I like to minimize the amount of time I spend sorting through emails &amp;amp; alerts, and part of that is making sure that I can determine the urgency &amp;amp; priority of an email alert at a mere glance. More importantly, it has to be equally useful to me at my desk &amp;amp; on my mobile.&lt;/p&gt;</description></item><item><title>Restoring a SQL Server 2012 database in high availability</title><link>https://am2.co/2014/11/12/restoring-a-sql-server-2012-database-in-high-availability/</link><pubDate>Wed, 12 Nov 2014 14:42:35 -0500</pubDate><guid>https://am2.co/2014/11/12/restoring-a-sql-server-2012-database-in-high-availability/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/26889631/1948808"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a database which is in always-on high availability mode synchronized with another database on a different instance. How can I restore from a &lt;code&gt;.bak&lt;/code&gt; file into the primary database using T-SQL?&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m new to high availability and I&amp;rsquo;ve been advised that I need to take the database out of high availability before I can do a restore and then put it back in high availability again but I&amp;rsquo;m not sure.&lt;/p&gt;</description></item><item><title>Moving Replication to a new server (without re-snapshotting)</title><link>https://am2.co/2014/07/08/moving-replication-to-a-new-server-without-re-snapshotting/</link><pubDate>Tue, 08 Jul 2014 19:57:00 -0400</pubDate><guid>https://am2.co/2014/07/08/moving-replication-to-a-new-server-without-re-snapshotting/</guid><description>&lt;h3 id="background"&gt;Background&lt;/h3&gt;&#10;&lt;figure class="wp-caption alignright" style="max-width:400px"&gt;&lt;a href="https://youtu.be/A0inwcbSPHY" target="_blank"&gt;&lt;img src="https://am2.co/wp-content/uploads/jakob-owens-109151-unsplash.jpg" alt="" width="400" height="266" /&gt;&lt;/a&gt; The guy in this picture is a Snapshot Agent&lt;/figure&gt;&#10;&lt;p&gt;At work, we make very extensive use of transactional replication. We have dozens of publications. Most publications have two or three subscribers. We replicate across domains, across subnets, across geographies. We use both push &amp;amp; pull replication (we&amp;rsquo;ve found pull works best when crossing the globe).&lt;/p&gt;</description></item><item><title>sp_get_basetable_list</title><link>https://am2.co/2014/05/22/sp_get_basetable_list/</link><pubDate>Thu, 22 May 2014 15:18:00 -0400</pubDate><guid>https://am2.co/2014/05/22/sp_get_basetable_list/</guid><description>&lt;p&gt;At work, we make extensive use of views &amp;amp; synonyms. The reasons are complex (and fodder for another post), but here&amp;rsquo;s a simplified example:&lt;/p&gt;&#10;&lt;blockquote&gt;Pricing data is updated multiple times per day, and we want to keep multiple generations of the pricing table online. By pointing the synonym to the latest pricing table, we can redirect users to the current/correct data. If there's a problem, we can "roll back" the latest pricing updates by simply pointing the synonym back to the prior generation of pricing data.&lt;/blockquote&gt;&#10;&lt;p&gt;Obviously, this can create some confusion when you do need to find the actual table (eg, to see indexes, or to update data). What pricing table is the real pricing table?&#10;Sure&amp;ndash; you can query system views to find out the real table(s) referenced by the synonym or view.&#10;When you do this hundreds (or thousands) of times, &lt;a href="http://xkcd.com/1205/"&gt;it can really add up.&lt;/a&gt; Time to automate.&lt;/p&gt;</description></item><item><title>SQL Server 2012 always-on backup, full vs copy-only</title><link>https://am2.co/2014/04/25/sql-server-2012-always-on-backup-full-vs-copy-only/</link><pubDate>Fri, 25 Apr 2014 19:19:45 -0400</pubDate><guid>https://am2.co/2014/04/25/sql-server-2012-always-on-backup-full-vs-copy-only/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/63946/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need a quick clarification on copy-only backup vs full backup as it pertains to transaction log numbering and restore if required.&lt;/p&gt;&#10;&lt;p&gt;I have SQL Server 2012 setup with always on for multiple databases. The availability groups are setup with preferred backup on replica.&lt;/p&gt;</description></item><item><title>some SQL Server MSX targets show as Normal, Blocked</title><link>https://am2.co/2012/03/27/some-sql-server-msx-targets-show-as-normal-blocked/</link><pubDate>Tue, 27 Mar 2012 12:19:30 -0400</pubDate><guid>https://am2.co/2012/03/27/some-sql-server-msx-targets-show-as-normal-blocked/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/15681/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I've centralized my farm's jobs in MSX, covering about 70 instances of SQL Server. Seemingly randomly, at least once a week, several instances will stop accepting instructions. Within the MSX window Manage Target Servers, instead of all instances showing as &lt;strong&gt;Normal&lt;/strong&gt;, they show as &lt;strong&gt;Normal, Blocked&lt;/strong&gt;. I have failed to figure out why this happens. Defecting and re-enlisting usually cures this ill, but that means having to re-add that target in any appropriate jobs, so I would rather resolve the cause than endure the workaround. &lt;/p&gt;</description></item></channel></rss>