<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Stack Exchange on Andy M Mallon - AM²</title><link>https://am2.co/category/stack-exchange/</link><description>Recent content in Stack Exchange on Andy M Mallon - AM²</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 11 Nov 2024 17:21:05 -0500</lastBuildDate><atom:link href="https://am2.co/category/stack-exchange/index.xml" rel="self" type="application/rss+xml"/><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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&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;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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 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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&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&gt;&lt;em&gt;asked &lt;a href="https://dba.stackexchange.com/q/306069/52344" rel="noopener" target="_blank"&gt;2022-01-13&lt;/a&gt; by &lt;a href="https://dba.stackexchange.com/users/246235" rel="noopener" target="_blank"&gt;Mark_72&lt;/a&gt;&lt;/em&gt;&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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&gt;&lt;em&gt;asked &lt;a href="https://dba.stackexchange.com/q/299456/52344" rel="noopener" target="_blank"&gt;2021-09-12&lt;/a&gt; by &lt;a href="https://dba.stackexchange.com/users/176952" rel="noopener" target="_blank"&gt;Avi&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;h1 id="not-in-sql-server"&gt;Not in SQL Server&lt;/h1&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>Function to create SQL TABLE does not works well using Powershell</title><link>https://am2.co/2021/09/02/function-to-create-sql-table-does-not-works-well-using-powershell/</link><pubDate>Thu, 02 Sep 2021 11:41:40 -0400</pubDate><guid>https://am2.co/2021/09/02/function-to-create-sql-table-does-not-works-well-using-powershell/</guid><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/q/69030492/1948808"&gt;&lt;img src="https://am2.co/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need to get the values from a Excel Sheet (in a shared folder) to export it and then create a SQL Table in my instance. After of this I will execute a Stored Procedure (I already created) in order to create extended properties for a specific schema on tables,columns and rows.&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;amp;&lt;/span&gt;&lt;span class="n"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&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;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;=&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;gt&lt;/span&gt;&lt;span class="p"&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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&gt;&lt;em&gt;asked &lt;a href="https://dba.stackexchange.com/q/276113/52344" rel="noopener" target="_blank"&gt;2020-09-25&lt;/a&gt; by Rafay Pervaiz&lt;/em&gt;&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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&gt;&lt;em&gt;asked &lt;a href="https://stackoverflow.com/q/72295228/1948808" rel="noopener" target="_blank"&gt;2022-05-18&lt;/a&gt; by &lt;a href="https://stackoverflow.com/users/4715808" rel="noopener" target="_blank"&gt;mortu&lt;/a&gt;&lt;/em&gt;&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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&gt;&lt;em&gt;asked &lt;a href="https://dba.stackexchange.com/q/226393/52344" rel="noopener" target="_blank"&gt;2019-01-05&lt;/a&gt; by &lt;a href="https://dba.stackexchange.com/users/169407" rel="noopener" target="_blank"&gt;Kevin Wilkie&lt;/a&gt;&lt;/em&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;amp;lt;account-name&amp;amp;gt;.blob.core.windows.net/&amp;amp;lt;container-name&amp;amp;gt;/&amp;amp;lt;filename&amp;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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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&gt;&lt;em&gt;asked &lt;a href="https://dba.stackexchange.com/q/171187/52344" rel="noopener" target="_blank"&gt;2017-04-17&lt;/a&gt; by &lt;a href="https://dba.stackexchange.com/users/109681" rel="noopener" target="_blank"&gt;Bharath Kuamr reddy&lt;/a&gt;&lt;/em&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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&gt;&lt;em&gt;asked &lt;a href="https://dba.stackexchange.com/q/158725/52344" rel="noopener" target="_blank"&gt;2016-12-20&lt;/a&gt; by &lt;a href="https://dba.stackexchange.com/users/113328" rel="noopener" target="_blank"&gt;dwkd&lt;/a&gt;&lt;/em&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</description></item><item><title>PowerShell can't see network locations after SQLPS module is loaded</title><link>https://am2.co/2016/08/15/powershell-cant-see-network-locations-after-sqlps-module-is-loaded/</link><pubDate>Mon, 15 Aug 2016 11:38:16 -0400</pubDate><guid>https://am2.co/2016/08/15/powershell-cant-see-network-locations-after-sqlps-module-is-loaded/</guid><description>&lt;p&gt;&lt;a href="https://superuser.com/q/1113679/630094"&gt;&lt;img src="https://am2.co/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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 automate a script that backups a database in one environment, copies it to the other, then restores it there. But there&amp;rsquo;s some strange behavior going on.&lt;/p&gt;&#10;&lt;p&gt;First, I try to access a network location. Works like a bliss:&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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;</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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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/wp-content/uploads/blockquote.png" alt="clip art of &#10;a double-quote character" width="100" height="75" class="alignleft size-full wp-image-55062" /&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>