<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SQL Server on Andy M Mallon - AM²</title><link>https://am2.co/tag/sql-server/</link><description>Recent content in SQL Server on Andy M Mallon - AM²</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 18 Nov 2022 15:04:29 -0500</lastBuildDate><atom:link href="https://am2.co/tag/sql-server/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Modulo Function gives the wrong value?</title><link>https://am2.co/2022/11/18/sql-modulo-function-gives-the-wrong-value/</link><pubDate>Fri, 18 Nov 2022 15:04:29 -0500</pubDate><guid>https://am2.co/2022/11/18/sql-modulo-function-gives-the-wrong-value/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/319890/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In Javascript, Excel, Python, and a scientific calculator, the modulo operation&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;34086&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1576962834&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="c1"&gt;-- python&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;MOD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;34086&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1576962834&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="c1"&gt;-- Excel function&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;gives a value of &lt;code&gt;113.84230371659942&lt;/code&gt;. (Or something very close to that, depending on number of decimal places and rounding.)&lt;/p&gt;</description></item><item><title>What ports to open for sql server behind secure domain firewall</title><link>https://am2.co/2022/08/25/what-ports-to-open-for-sql-server-behind-secure-domain-firewall/</link><pubDate>Thu, 25 Aug 2022 21:34:17 -0400</pubDate><guid>https://am2.co/2022/08/25/what-ports-to-open-for-sql-server-behind-secure-domain-firewall/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/316082/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We are trying to solve connectivity issues for one of the app trying to pull data from very secured sql server behind firewall. I am not that expertise in security but need help on how to proceed in opening ports for that app to pull data from sql server behind secure domain.&lt;/p&gt;</description></item><item><title>GRANT ADMINISTER Database Bulk Operations - Incorrect syntax near ADMINISTER</title><link>https://am2.co/2022/05/23/grant-administer-database-bulk-operations-incorrect-syntax-near-administer/</link><pubDate>Mon, 23 May 2022 01:51:34 -0400</pubDate><guid>https://am2.co/2022/05/23/grant-administer-database-bulk-operations-incorrect-syntax-near-administer/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/312469/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to import a bacpac file to my SQL Server Express 2016.&#10;An exception is thrown during the import with&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;GRANT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ADMINISTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Database&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Bulk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Operations&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;MyUser&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Returns:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;Incorrect syntax near 'ADMINISTER'.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;I am running the import as the &lt;code&gt;sa&lt;/code&gt; user. Later when I try to run the SQL line directly, the same error is thrown. What can I do to resolve this?&lt;/p&gt;</description></item><item><title>Temporarily turn on Cascade Delete</title><link>https://am2.co/2022/04/20/temporarily-turn-on-cascade-delete/</link><pubDate>Wed, 20 Apr 2022 10:02:25 -0400</pubDate><guid>https://am2.co/2022/04/20/temporarily-turn-on-cascade-delete/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/312379/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This has probably been asked before, but I couldn't find the answer.&lt;/p&gt;&#10;&lt;p&gt;I have a complex datamodel in sql-server-20XX (more likely to be something old) in which cascade delete has been turned off (by design).&lt;/p&gt;&#10;&lt;p&gt;A large chunk of our database has been sold (I can make the distinction on the top-level) and there are reasons why we want to delete that data. I want to do that in a single script, in which I first turn on cascade delete, than delete all the data, than turn off cascade delete again, but I can't find the correct syntax.&lt;/p&gt;</description></item><item><title>Allow create table (dynamic name) and insert but nothing else</title><link>https://am2.co/2022/02/14/allow-create-table-dynamic-name-and-insert-but-nothing-else/</link><pubDate>Mon, 14 Feb 2022 13:43:43 -0500</pubDate><guid>https://am2.co/2022/02/14/allow-create-table-dynamic-name-and-insert-but-nothing-else/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/307467/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm trying to find a way to allow an application to create tables and insert data into them on a SQL Server 2019 while protecting from injection attacks in case the app credentials would leak. My experience is limited when it comes to writing code that can run in parallel and writing dynamic sql that is protected from sql injection attacks.&lt;br /&gt;&#10;The table name is based on input from the application, i.e. if the input is 'nds' the table name should be lake.nds_raw_log.&lt;br /&gt;&#10;It is my understanding that there is no way to do this via directly granting permissions to the role for this application since creating tables is not separated from deleting or altering them.&lt;/p&gt;</description></item><item><title>CASE statement issue</title><link>https://am2.co/2022/01/13/case-statement-issue/</link><pubDate>Thu, 13 Jan 2022 19:52:17 -0500</pubDate><guid>https://am2.co/2022/01/13/case-statement-issue/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/306069/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Can anyone help with this error?&lt;/p&gt;&#10;&lt;p&gt;SQL:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;InvoiceDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BillingAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BillingCity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;CASE&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;THEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Baseline Purchase&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BETWEEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;THEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Low Purchase&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Total&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BETWEEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;THEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Target Purchase&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ELSE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Top Performer&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PurchaseType&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;PurchaseType&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Top Performer&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BY&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BillingCity&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="errorMsg"&gt;Error:&#10;Msg 207, Level 16, State 1, Line 13&#10;Invalid column name 'PurchaseType'.&lt;/div&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/306069/52344" rel="noopener" target="_blank"&gt;2022-01-13&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/246235" rel="noopener" target="_blank"&gt;Mark_72&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Which install kit installs sqlcmd.exe?</title><link>https://am2.co/2021/12/12/which-install-kit-installs-sqlcmd-exe/</link><pubDate>Sun, 12 Dec 2021 19:58:18 -0500</pubDate><guid>https://am2.co/2021/12/12/which-install-kit-installs-sqlcmd-exe/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/303854/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I recently had to uninstall Visual Studio 2012 and DTS, then install VS 2017 and DTS again. Afterwards, The directory containing &lt;code&gt;sqlcmd.exe&lt;/code&gt; was not in my &lt;code&gt;PATH&lt;/code&gt; variable. I installed the following.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;vs_Professional&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;vs2017&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;SSDT&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Setup&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ENU&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;vs2017&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Should either of these kits install &lt;code&gt;sqlcmd.exe&lt;/code&gt;? If not, which tool will install it? I need one that will work with SQL Server 2012+.&lt;/p&gt;</description></item><item><title>Order by one column if not null, otherwise by another column, columns are of not matching types</title><link>https://am2.co/2021/11/28/order-by-one-column-if-not-null-otherwise-by-another-column-columns-are-of-not-matching-types/</link><pubDate>Sun, 28 Nov 2021 18:14:16 -0500</pubDate><guid>https://am2.co/2021/11/28/order-by-one-column-if-not-null-otherwise-by-another-column-columns-are-of-not-matching-types/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/303220/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have an application that uses PostgreSQL as RDBMS. There is a table containing orders placed by customers. The table has an &lt;code&gt;id&lt;/code&gt; as primary key, an &lt;code&gt;order_number&lt;/code&gt; (integer) and a &lt;code&gt;created_at&lt;/code&gt; field (timestamp). &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;created_at&lt;/code&gt; are assigned automatically when the row is created, the &lt;code&gt;order_number&lt;/code&gt; is assigned &amp;quot;manually&amp;quot; (when the person performing the order entry process receives the order confirmation, he presses a button and the order_number is assigned as &lt;code&gt;MAX(order_number) + 1&lt;/code&gt;, this can happen almost immediately or after a few days, or the order can be cancelled so it never receives a number). In the table there are quite a lot of rows with &lt;code&gt;NULL&lt;/code&gt; in the &lt;code&gt;order_number&lt;/code&gt; column: the cancelled and pending confirmation orders. This is an excerpt from the table:&lt;/p&gt;</description></item><item><title>Database context for sys.databases and sys.master_files</title><link>https://am2.co/2021/11/15/database-context-for-sys-databases-and-sys-master_files/</link><pubDate>Mon, 15 Nov 2021 11:45:13 -0500</pubDate><guid>https://am2.co/2021/11/15/database-context-for-sys-databases-and-sys-master_files/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/302628/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a query that pulls information for a database from the following tables&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;sys.master_files&lt;/li&gt;&#10;&lt;li&gt;sys.databases&lt;/li&gt;&#10;&lt;li&gt;sys.filegroups&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Currently, the context set is the specific database which I want to query about.&#10;But if the database is in a mode such that &lt;code&gt;USE DB_NAME&lt;/code&gt; doesn't work,&#10;is it okay to use &lt;code&gt;USE master&lt;/code&gt;?&#10;Since I am adding a &lt;strong&gt;where clause on the basis of &lt;code&gt;DB_NAME&lt;/code&gt;&lt;/strong&gt; will &lt;code&gt;USE DB_NAME&lt;/code&gt; versus &lt;code&gt;USE master&lt;/code&gt; make any difference?&lt;/p&gt;</description></item><item><title>SQL Server service - Not Starting With Automatic Startup, "The system cannot find the file specified", but starts fine manually</title><link>https://am2.co/2021/10/29/sql-server-service-not-starting-with-automatic-startup-the-system-cannot-find-the-file-specified-but-starts-fine-manually/</link><pubDate>Fri, 29 Oct 2021 18:56:27 -0400</pubDate><guid>https://am2.co/2021/10/29/sql-server-service-not-starting-with-automatic-startup-the-system-cannot-find-the-file-specified-but-starts-fine-manually/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/301898/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;This is a weird one, and I've run out of ideas for how to go about troubleshooting this. Here's the issue, best as I can sum it up.&lt;/p&gt;&#10;&lt;p&gt;The SQL Server engine and Agent services are not started when the server first boots when they're set to Automatic. Looked through the Event Viewer, and found these errors:&lt;/p&gt;</description></item><item><title>Database Sizes error; Arithmetic overflow error converting expression to data type int</title><link>https://am2.co/2021/10/01/database-sizes-error-arithmetic-overflow-error-converting-expression-to-data-type-int/</link><pubDate>Fri, 01 Oct 2021 12:53:23 -0400</pubDate><guid>https://am2.co/2021/10/01/database-sizes-error-arithmetic-overflow-error-converting-expression-to-data-type-int/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/300451/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am using the below query to pull back database sizes for our SQL instances.&lt;/p&gt;&#10;&lt;p&gt;This cannot pull data larger than 2TB back because of the maximum number the int data type can pull back. How do I go about altering the query to return the database size, no matter how large the dbs?&lt;/p&gt;</description></item><item><title>Is it ok to change drive names/labels (NOT Drive Letters!)</title><link>https://am2.co/2021/09/01/is-it-ok-to-change-drive-names-labels-not-drive-letters/</link><pubDate>Wed, 01 Sep 2021 20:50:32 -0400</pubDate><guid>https://am2.co/2021/09/01/is-it-ok-to-change-drive-names-labels-not-drive-letters/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298926/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I realize this is likely a simplistic question but my searches only return results for Drive Letters or Database names if I include SQL Server. Please feel free to point me to existing articles or answers, and my apologies in advance :)&lt;/p&gt;</description></item><item><title>What are the .BCP files inside a .bacpak file?</title><link>https://am2.co/2021/08/16/what-are-the-bcp-files-inside-a-bacpak-file/</link><pubDate>Mon, 16 Aug 2021 15:00:01 -0400</pubDate><guid>https://am2.co/2021/08/16/what-are-the-bcp-files-inside-a-bacpak-file/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/298113/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Diving on dba.stackexchange.com I found a &lt;a href="https://dba.stackexchange.com/questions/137993/why-is-a-bacpac-file-so-small-compared-to-a-bak-file-of-the-same-database"&gt;nice answer&lt;/a&gt; that teach me how to open a &lt;code&gt;.bacpac&lt;/code&gt; file with File Explorer.&lt;/p&gt;&#10;&lt;p&gt;I gave it a try with the database &lt;code&gt;AdventureWorks2008R2&lt;/code&gt; and all I did was:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Save the database as &lt;code&gt;.bacpac&lt;/code&gt; file&lt;/li&gt;&#10;&lt;li&gt;Rename the file extension to &lt;code&gt;.zip&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Unzip it&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;And there you go, you can see the tables of the database as folders and inside each folder you can see the raw data.&lt;/p&gt;</description></item><item><title>Getting the first Monday after the third Friday</title><link>https://am2.co/2021/08/12/getting-the-first-monday-after-the-third-friday/</link><pubDate>Thu, 12 Aug 2021 23:48:40 -0400</pubDate><guid>https://am2.co/2021/08/12/getting-the-first-monday-after-the-third-friday/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/297986/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have seen on this site how to get the the third Friday of the month:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weekday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Friday&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datepart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;datepart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;quote_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;How would I get the first Monday after this third Friday?&lt;/p&gt;</description></item><item><title>Identify all tables with an identity column</title><link>https://am2.co/2021/07/02/identify-all-tables-with-an-identity-column/</link><pubDate>Fri, 02 Jul 2021 18:04:50 -0400</pubDate><guid>https://am2.co/2021/07/02/identify-all-tables-with-an-identity-column/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/295195/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Is there a query I can run that will show me all tables with an identity column? Trying to figure out if there are any identity based tables whose current identity is nearing upper bound of int32 or int64.&lt;/p&gt;</description></item><item><title>Why does SQL Server convert floats to scientific notation?</title><link>https://am2.co/2021/06/28/why-does-sql-server-convert-floats-to-scientific-notation/</link><pubDate>Mon, 28 Jun 2021 15:28:50 -0400</pubDate><guid>https://am2.co/2021/06/28/why-does-sql-server-convert-floats-to-scientific-notation/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/294935/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I came across some weird behavior: While passing a float value into a varchar column, the values are getting converted from integers into scientific notation, and it's that scientific notation that gets stored as a string.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;OBJECT_Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tempdb..#whydis&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;begin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;drop&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;OBJECT_Id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tempdb..#ImSeriously&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;begin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;drop&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;table&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;insert&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;into&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BigID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495591&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495289&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495610&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495611&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495609&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495592&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1495686&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INTO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bigID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BigID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;whydis&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="n"&gt;ImSeriously&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;results look like this:&lt;/p&gt;</description></item><item><title>OLE DB provider "MSOLEDBSQL" with SQL Server not supported?</title><link>https://am2.co/2021/06/28/ole-db-provider-msoledbsql-with-sql-server-not-supported/</link><pubDate>Mon, 28 Jun 2021 15:28:05 -0400</pubDate><guid>https://am2.co/2021/06/28/ole-db-provider-msoledbsql-with-sql-server-not-supported/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/279226/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have been using linked server with the old provider (SQLNCLI) without any issue, as recommended &lt;a href="https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addlinkedserver-transact-sql?view=sql-server-ver15#arguments" rel="noreferrer"&gt;by Microsoft&lt;/a&gt;, I'm planning to switch to new provider (MSOLEDBSQL). I'm able to add linked server using following T-SQL after installing &lt;a href="https://www.microsoft.com/en-us/download/details.aspx?id=56730" rel="noreferrer"&gt;the drivers&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;EXEC&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sp_addlinkedserver&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SQL02\DEV1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;srvproduct&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;MSOLEDBSQL&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;datasrc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SQL02,1933&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Unfortunately, getting following error when I try to query new linked server:&lt;/p&gt;</description></item><item><title>When to partition table in SQL Server based on the amount of memory on server</title><link>https://am2.co/2021/06/25/when-to-partition-table-in-sql-server-based-on-the-amount-of-memory-on-server/</link><pubDate>Fri, 25 Jun 2021 18:12:44 -0400</pubDate><guid>https://am2.co/2021/06/25/when-to-partition-table-in-sql-server-based-on-the-amount-of-memory-on-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/294826/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I understand that table partitioning is mostly done for data management. I understand that table maintenance becomes more difficult for large tables, since e.g. an index rebuild cannot fit in memory or because e.g. sorts scale with O(n*log(n)) and this causes extra problems with large tables.&lt;/p&gt;</description></item><item><title>SQL Server Configuration - Disabling the "Allow Remote Connections to this Server" Option</title><link>https://am2.co/2021/06/07/sql-server-configuration-disabling-the-allow-remote-connections-to-this-server-option/</link><pubDate>Mon, 07 Jun 2021 21:16:59 -0400</pubDate><guid>https://am2.co/2021/06/07/sql-server-configuration-disabling-the-allow-remote-connections-to-this-server-option/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/293896/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;My organization had a security audit and was told that we need to DISABLE the &amp;quot;allow remote connection to this server&amp;quot; option for all of our SQL Servers. What impact would this have on connection to the SQL Server via Management Studio (SSMS) from a client machine/desktop or from a web app that might use a connection string or any other external app? All of the documentation I see regarding connectivity issues to a SQL Server seem to include &amp;quot;ENABLING&amp;quot; this option as a solution. Is there a workaround that will allow us to disable it but still allow the access we need from the target clients?&lt;/p&gt;</description></item><item><title>How do I preserve leading zeros for varchar field?</title><link>https://am2.co/2021/05/17/how-do-i-preserve-leading-zeros-for-varchar-field/</link><pubDate>Mon, 17 May 2021 17:00:31 -0400</pubDate><guid>https://am2.co/2021/05/17/how-do-i-preserve-leading-zeros-for-varchar-field/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/291730/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;When saving a number with leading zeros into a string variable or column, leading zeros are truncated.&lt;/p&gt;&#10;&lt;p&gt;When I run this query:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;declare&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;nvarchar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;011&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;varchar&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The result I get is 11.&lt;/p&gt;&#10;&lt;p&gt;Is there any way to get 011?&lt;/p&gt;</description></item><item><title>Commit or rollback SQLServer-SQLTransaction when no data changed</title><link>https://am2.co/2021/05/07/commit-or-rollback-sqlserver-sqltransaction-when-no-data-changed/</link><pubDate>Fri, 07 May 2021 16:11:54 -0400</pubDate><guid>https://am2.co/2021/05/07/commit-or-rollback-sqlserver-sqltransaction-when-no-data-changed/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/291197/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;we use the &lt;a target="_blank" rel="noopener"&gt;SqlTransaction&lt;/a&gt;-class in the backend to access data stored in the MS-SQLServer.&lt;/p&gt;&#10;&lt;p&gt;In some cases we definitely know that no data were changed by this transaction (and no errors occurred).&#10;So the question is: How to close transactions in these cases?&#10;Shall we use &lt;code&gt;Commit()&lt;/code&gt; or &lt;code&gt;Rollback()&lt;/code&gt;, or none of this both functions or something else?&#10;The aim is to find the most performant way to finish the transaction in a &amp;quot;reasonable&amp;quot; way.&lt;/p&gt;</description></item><item><title>log send queue size and redo queue size in AG</title><link>https://am2.co/2020/10/19/log-send-queue-size-and-redo-queue-size-in-ag/</link><pubDate>Mon, 19 Oct 2020 22:44:00 -0400</pubDate><guid>https://am2.co/2020/10/19/log-send-queue-size-and-redo-queue-size-in-ag/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/278324/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am trying to figure out the way to monitor these 2 events&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;p&gt;log send queue size - I can see this in perfmon&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;p&gt;Redo queue size - I can see in dmv but not in perfmon counter&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Is there any way of using perfmon so that I can calculate the redo queue size even thought the counter is not available in perfmon?&lt;/p&gt;</description></item><item><title>How to dig deeper into ASYNC_NETWORK_IO waits</title><link>https://am2.co/2020/08/15/how-to-dig-deeper-into-async_network_io-waits/</link><pubDate>Sat, 15 Aug 2020 00:48:17 -0400</pubDate><guid>https://am2.co/2020/08/15/how-to-dig-deeper-into-async_network_io-waits/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/273788/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I've been handed a graph that comes from SolarWinds showing top wait events broken down by day. The last 2 days there's a part of the daily color coded bar representing a total of 3 hours for ASYNC_NETWORK_IO. Still trying to see if I can get access to Solar Winds panels to try and see if it offers a drill down into the graph or not.&lt;/p&gt;</description></item><item><title>Why the instance name of SQL Server Express is changing?</title><link>https://am2.co/2020/05/21/why-the-instance-name-of-sql-server-express-is-changing/</link><pubDate>Thu, 21 May 2020 08:12:15 -0400</pubDate><guid>https://am2.co/2020/05/21/why-the-instance-name-of-sql-server-express-is-changing/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/267593/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm working on a web app which is using &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10; &lt;p&gt;SQL Server Express (Microsoft SQL Server 2016 (SP1) (KB3182545) -&#10; 13.0.4001.0 (X64) Oct 28 2016 18:17:30 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 6.3 &#10; (Build 18362: )).&lt;/p&gt;&#10;&lt;/div&gt;</description></item><item><title>How to store real-time data to database</title><link>https://am2.co/2020/02/23/how-to-store-real-time-data-to-database/</link><pubDate>Sun, 23 Feb 2020 18:38:30 -0500</pubDate><guid>https://am2.co/2020/02/23/how-to-store-real-time-data-to-database/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/260351/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Here is my situation:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;I have a WebSocket connection that feeds me data real-time&lt;/li&gt;&#10;&lt;li&gt;I have an async callback function that gets the data and inserts into a queue &lt;/li&gt;&#10;&lt;li&gt;I have another thread that reads from the queue and stores it into the Postgres database, one row at a time (using python's psycopg2 library)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The problem is the real-time data comes in faster than the time it takes to insert into the database, and in a couple of hours, the server runs out of memory. (Is this because psycopg2 library is slow?)&lt;/p&gt;</description></item><item><title>Job waiting on CXCONSUMER</title><link>https://am2.co/2020/01/09/job-waiting-on-cxconsumer/</link><pubDate>Thu, 09 Jan 2020 12:09:54 -0500</pubDate><guid>https://am2.co/2020/01/09/job-waiting-on-cxconsumer/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/257011/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have got a procedure on SQL Server agent jobs and this job started to hang on transaction for many hours with wait stats CXCONSUMER and never complete. The problem is after we noticed that it was hanging we kill the job and started manually during and the job was working fine and completing. But right now neither starting manually or on sql agent job seems never completing and hanging on waits with CXCONSUMER. &lt;/p&gt;</description></item><item><title>INSERT EXEC statement cannot be nested</title><link>https://am2.co/2019/12/13/insert-exec-statement-cannot-be-nested/</link><pubDate>Fri, 13 Dec 2019 23:16:21 -0500</pubDate><guid>https://am2.co/2019/12/13/insert-exec-statement-cannot-be-nested/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/255615/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a stored proc spGetSites that returns three columns for SiteName, SiteId and UnitCount. The stored proc runs perfectly fine. &#10;I'm trying to store the results of the stored proc to a temp table @Site to use for my report with below syntax. This time I got an error message: "INSERT EXEC statement cannot be nested"&lt;/p&gt;</description></item><item><title>Monetary value in integer over decimal datatype</title><link>https://am2.co/2019/09/15/monetary-value-in-integer-over-decimal-datatype/</link><pubDate>Sun, 15 Sep 2019 09:08:25 -0400</pubDate><guid>https://am2.co/2019/09/15/monetary-value-in-integer-over-decimal-datatype/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/248815/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have came across several articles that mentioned that advise on not to store monetary value as decimal, but use integer instead.&#10;The reasoning that it does not store actual value and will cause some rounding difference/errors.&#10;But i have yet ever participate in any project that use an integer datatype for monetary value in database storage.&lt;/p&gt;</description></item><item><title>Managed Instance Restart</title><link>https://am2.co/2019/01/05/managed-instance-restart/</link><pubDate>Sat, 05 Jan 2019 02:07:58 -0500</pubDate><guid>https://am2.co/2019/01/05/managed-instance-restart/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/226393/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;Does anyone know how to restart a SQL Server Managed Instance?&lt;/p&gt;&#10;&lt;p&gt;The stop / start / reset are all grayed out, so that’s really. It an option.&lt;/p&gt;&#10;&lt;p&gt;Any thoughts?&lt;/p&gt;&#10;&lt;p&gt;Thanks...&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/226393/52344" rel="noopener" target="_blank"&gt;2019-01-05&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/169407" rel="noopener" target="_blank"&gt;Kevin Wilkie&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;p&gt;You don't restart Managed Instance. The beauty of PaaS is that the cloud service provider ensures that you get a certain uptime SLA-- 99.99% in this case. &lt;/p&gt;</description></item><item><title>Installation of SQL Server Express LocalDB 2017</title><link>https://am2.co/2018/11/04/installation-of-sql-server-express-localdb-2017/</link><pubDate>Sun, 04 Nov 2018 14:14:51 -0500</pubDate><guid>https://am2.co/2018/11/04/installation-of-sql-server-express-localdb-2017/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/221745/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I want to install Microsoft SQL Server LocalDB 2017 on my system. I downloaded SQL Server Express Setup (about 5.1 MB). Then I opened it and chose 'Download Media' option and then chose LocalDB. Then it downloaded SqlLocalDB.msi setup (about 45.9 MB). I ran the setup and installed it on my computer. I don't know what to do next. Can someone help me, please?&lt;/p&gt;</description></item><item><title>SQL Visual Studio Find and Replace in Publish Profile</title><link>https://am2.co/2018/10/29/sql-visual-studio-find-and-replace-in-publish-profile/</link><pubDate>Mon, 29 Oct 2018 20:48:28 -0400</pubDate><guid>https://am2.co/2018/10/29/sql-visual-studio-find-and-replace-in-publish-profile/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/221293/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have source control in Visual Studio Database Projects (SSDT). To make cross database references, we utilize something like this below in Project References.&lt;/p&gt;&#10;&lt;p&gt;We need Project references, since Otherdatabase, can choose between two options at our company. Most of the time, its 90% Database A, and 10% Database B.&lt;/p&gt;</description></item><item><title>How do you SUM a column without having its name?</title><link>https://am2.co/2018/09/22/how-do-you-sum-a-column-without-having-its-name/</link><pubDate>Sat, 22 Sep 2018 10:54:20 -0400</pubDate><guid>https://am2.co/2018/09/22/how-do-you-sum-a-column-without-having-its-name/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/218315/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm stuck in a way that how to do sum on a column let's say first column of a table (result from another query) without knowing the column name with something like column position id.&lt;/p&gt;&#10;&lt;p&gt;it's something like this&lt;/p&gt;</description></item><item><title>Prevent Modification of dbo objects while allowing other schemas to be modified</title><link>https://am2.co/2017/04/20/prevent-modification-of-dbo-objects-while-allowing-other-schemas-to-be-modified/</link><pubDate>Thu, 20 Apr 2017 14:16:40 -0400</pubDate><guid>https://am2.co/2017/04/20/prevent-modification-of-dbo-objects-while-allowing-other-schemas-to-be-modified/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171523/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a vendor solution that uses a sql server (2008r2) database. We are allowed to do anything we want in our own schema, but cannot modify dbo objects without vendor permission. Any customization we make is in our own schema (cust). We have full control of this server and have always allowed sysadmin rights to any developer. Lately, I've noticed these rules have not been followed, so I want to see if I can set up permissions to stop this in the first place.&lt;/p&gt;</description></item><item><title>Load balancing reads SQL Server 2016 AG</title><link>https://am2.co/2017/04/19/load-balancing-reads-sql-server-2016-ag/</link><pubDate>Wed, 19 Apr 2017 18:21:44 -0400</pubDate><guid>https://am2.co/2017/04/19/load-balancing-reads-sql-server-2016-ag/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171438/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm trying to balance read traffic between two SQL Server 2016 Enterprise Edition instances (Primary and Secondary) using availability groups and the read only routing. &lt;/p&gt;&#10;&lt;p&gt;Here is my current setup:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;The servers are in AWS in two different AZ&lt;/li&gt;&#10;&lt;li&gt;The servers are in a failover cluster without shared storage&lt;/li&gt;&#10;&lt;li&gt;AG is enabled on both instances&lt;/li&gt;&#10;&lt;li&gt;The databases in an Availability Group have the "Readable Secondary" option set to Yes&lt;/li&gt;&#10;&lt;li&gt;I've setup the AG with the read only routing on both the current primary and secondary instances&lt;/li&gt;&#10;&lt;li&gt;Adding the read only switch in my application connection string allows me to route traffic to the secondary &lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Is there a way to have the AG Listener load balance read only traffic between the primary and secondary?&lt;/p&gt;</description></item><item><title>If the Database is in Readonly mode how can we drop/remove those unused roles</title><link>https://am2.co/2017/04/17/if-the-database-is-in-readonly-mode-how-can-we-drop-remove-those-unused-roles/</link><pubDate>Mon, 17 Apr 2017 11:03:22 -0400</pubDate><guid>https://am2.co/2017/04/17/if-the-database-is-in-readonly-mode-how-can-we-drop-remove-those-unused-roles/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/171187/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;In SQL Server, if the Database is in &lt;code&gt;Read_only&lt;/code&gt; mode, can we drop/remove unused roles? Please let me know.&lt;/p&gt;&#10;&lt;p&gt;Thanks in advance&lt;/p&gt;&#10;&lt;p class="qa-attribution qa-attribution-asked"&gt;&lt;span class="qa-attribution-label"&gt;Asked&lt;/span&gt;&lt;span class="qa-attribution-date"&gt;&lt;a href="https://dba.stackexchange.com/q/171187/52344" rel="noopener" target="_blank"&gt;2017-04-17&lt;/a&gt;&lt;/span&gt;&lt;span class="qa-attribution-by"&gt;by&lt;/span&gt;&lt;span class="qa-attribution-user"&gt;&lt;a href="https://dba.stackexchange.com/users/109681" rel="noopener" target="_blank"&gt;Bharath Kuamr reddy&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="answer"&gt;Answer&lt;/h2&gt;&#10;&lt;p&gt;If a database is in &lt;code&gt;READ_ONLY&lt;/code&gt; mode, it is &lt;strong&gt;completely&lt;/strong&gt; read-only. The read-only-ness is not limited to user data, but &lt;em&gt;anything&lt;/em&gt; contained in the database. This means that both DML commands (ie, &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;), and DDL commands (ie, &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;ALTER&lt;/code&gt;, &lt;code&gt;DROP&lt;/code&gt;) are prohibited. &lt;/p&gt;</description></item><item><title>Releasing free space in mdf file to OS</title><link>https://am2.co/2017/04/10/releasing-free-space-in-mdf-file-to-os/</link><pubDate>Mon, 10 Apr 2017 13:29:43 -0400</pubDate><guid>https://am2.co/2017/04/10/releasing-free-space-in-mdf-file-to-os/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/170621/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have a 120GB database. There was table with 60GB of data which is useless and we have truncated it. &lt;/p&gt;&#10;&lt;p&gt;Now database size is 120GB with free space 60GB. The database will not grow up to 60GB in at least 3 months. So can we shrink the data file.&lt;/p&gt;</description></item><item><title>SQL Triggers not preventing insert</title><link>https://am2.co/2017/04/10/sql-triggers-not-preventing-insert/</link><pubDate>Mon, 10 Apr 2017 00:53:58 -0400</pubDate><guid>https://am2.co/2017/04/10/sql-triggers-not-preventing-insert/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/170564/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am having trouble getting a trigger to work. What it needs to do is to prevent any customer with last name Glass from being inserted into the database. This is what I have:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TRIGGER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;no_last_name_glass_trg&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;AFTER&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;DECLARE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;CUSTOMER_LAST&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SET&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;CUSTOMER_LAST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;INSERTED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_last&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;INSERTED&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;CUSTOMER_LAST&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Glass&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BEGIN&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ROLLBACK&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RAISERROR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Applicant Glass Denied&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The issue is when I add customers with last name of Glass, it inserts without throwing an error. Any ideas? I can make it work in Oracle, but the same method does not work in MS SQL.&lt;/p&gt;</description></item><item><title>Connecting to ReadOnly Secondary Replica of SQL Server via the Listener by Default</title><link>https://am2.co/2017/03/31/connecting-to-readonly-secondary-replica-of-sql-server-via-the-listener-by-default/</link><pubDate>Fri, 31 Mar 2017 00:56:41 -0400</pubDate><guid>https://am2.co/2017/03/31/connecting-to-readonly-secondary-replica-of-sql-server-via-the-listener-by-default/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/168708/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;We have the ApplicationIntent=ReadOnly properly routing our users to the Secondary ReadOnly replica. Is there a way to make this the default behavior?&lt;/p&gt;&#10;&lt;p&gt;Apparently the default behavior seems to be ReadWrite, and if you don't specify an ApplicationIntent it will redirect to the Primary server.&lt;/p&gt;</description></item><item><title>How to add 1100 columns in SQL Server</title><link>https://am2.co/2016/12/04/how-to-add-1100-columns-in-sql-server/</link><pubDate>Sun, 04 Dec 2016 06:49:07 -0500</pubDate><guid>https://am2.co/2016/12/04/how-to-add-1100-columns-in-sql-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/157115/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need 1100 columns in a single table.I already have 928 columns in same table, now I need to add new 150 columns.&lt;/p&gt;&#10;&lt;p&gt;I know SQL Server allow maximum 1024 columns.&lt;/p&gt;&#10;&lt;p&gt;Now I will not create new table. If I create new table and join my require table, I need to make changes in many places and this is not possible for me. So I want to add all columns in same table(require table).I know this is so tough to execute this table but presently I need to serve this requirement.&lt;/p&gt;</description></item><item><title>Is it possible to change the family_guid in MSSQL?</title><link>https://am2.co/2016/08/24/is-it-possible-to-change-the-family_guid-in-mssql/</link><pubDate>Wed, 24 Aug 2016 19:17:43 -0400</pubDate><guid>https://am2.co/2016/08/24/is-it-possible-to-change-the-family_guid-in-mssql/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/147801/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;So I have a bit of a problem with some databases I'm trying to migrate to amazon RDS&lt;/p&gt;&#10;&lt;p&gt;We have about 20 Databases that are all derivatives of others that all share the same &lt;code&gt;family_guid&lt;/code&gt; because they are based on backups of others. The problem is that amazon will not allow you to restore a DB that has the same &lt;code&gt;family_guid&lt;/code&gt; of another even if they are two separate databases. This is where my question comes in, Is it possible to change the guid or am I out of luck and will need to do some exports/imports on these databases.&lt;/p&gt;</description></item><item><title>Why is this explicit cast causing problems only with a Linked Server?</title><link>https://am2.co/2016/08/17/why-is-this-explicit-cast-causing-problems-only-with-a-linked-server/</link><pubDate>Wed, 17 Aug 2016 07:42:23 -0400</pubDate><guid>https://am2.co/2016/08/17/why-is-this-explicit-cast-causing-problems-only-with-a-linked-server/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/147039/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am querying data from a linked server through a view on the origin server.&#10;The view has to include a couple of standardized columns, such as &lt;code&gt;Created&lt;/code&gt;, &lt;code&gt;Modified&lt;/code&gt; and &lt;code&gt;Deleted&lt;/code&gt;, but in this case the table on the source server doesn't have any suitable info. The columns are therefore explicitly cast to their respective types. I updated the view, changing a column from &lt;/p&gt;</description></item><item><title>Users in SQL Server cluster</title><link>https://am2.co/2016/04/12/users-in-sql-server-cluster/</link><pubDate>Tue, 12 Apr 2016 12:17:30 -0400</pubDate><guid>https://am2.co/2016/04/12/users-in-sql-server-cluster/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/135057/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have created a 2012 WFC and SQL Server 2014 is clustered on it. The cluster works as expected but have a question on Users:&lt;/p&gt;&#10;&lt;p&gt;I added a windows domain group to the cluster as sysadmin. &lt;/p&gt;&#10;&lt;p&gt;When the user tries to log into SQL on the active server the users rights are not right. They can’t see anything. If the same user logs in from the no active server they have full admin rights, if they log in from their local machine they have the proper sysadmin rights. &lt;/p&gt;</description></item><item><title>Exclude All Matching Rows</title><link>https://am2.co/2016/04/08/exclude-all-matching-rows/</link><pubDate>Fri, 08 Apr 2016 17:14:26 -0400</pubDate><guid>https://am2.co/2016/04/08/exclude-all-matching-rows/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134791/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a table that has a unique ID, name, email, and some other fields. I want to match this table against another table on email, but sometimes emails are shared. The unique ID is not shared among tables, but I will input the ID into the other table when I have identified them. Name is not unique.&lt;/p&gt;</description></item><item><title>Convert row into concatenated string with column names included</title><link>https://am2.co/2016/04/06/convert-row-into-concatenated-string-with-column-names-included/</link><pubDate>Wed, 06 Apr 2016 15:53:55 -0400</pubDate><guid>https://am2.co/2016/04/06/convert-row-into-concatenated-string-with-column-names-included/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134555/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I have a table that is several hundred columns wide. Is there a way to convert each row into a single concatenated string with the column title included without having to list each single column in the query? &lt;/p&gt;&#10;&lt;p&gt;I'm doing this because the columns represents fields in an event report. I'm putting them back together so a person can read the report in a logical manner.&lt;/p&gt;</description></item><item><title>SQL Server: How to export database with linked servers</title><link>https://am2.co/2016/04/04/sql-server-how-to-export-database-with-linked-servers/</link><pubDate>Mon, 04 Apr 2016 10:27:53 -0400</pubDate><guid>https://am2.co/2016/04/04/sql-server-how-to-export-database-with-linked-servers/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134279/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I'm a web developer and I want to export a database to work on it in my local machine.&lt;/p&gt;&#10;&lt;p&gt;I'm using &lt;code&gt;generate script with data&lt;/code&gt;. the script is generated but without the linked servers used by some Views.&lt;/p&gt;&#10;&lt;p&gt;Is their a way to generate a full script with linked servers or do I have to create it manually with &lt;code&gt;sp_addlinkedserver&lt;/code&gt;?&lt;/p&gt;</description></item><item><title>Reduce MDF file size</title><link>https://am2.co/2016/04/01/reduce-mdf-file-size/</link><pubDate>Fri, 01 Apr 2016 17:26:01 -0400</pubDate><guid>https://am2.co/2016/04/01/reduce-mdf-file-size/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/134524/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I am working with a 500 GB SQL Server database. I need to reduce the size of the database data file after removing a large amount (50%) of the data.&lt;/p&gt;&#10;&lt;p&gt;I tried re indexing, it's good the database has de-fragmented. But the DB size is not reduced.&lt;/p&gt;</description></item><item><title>UFT to SQL Server conecction which is located at different domain</title><link>https://am2.co/2016/03/29/uft-to-sql-server-conecction-which-is-located-at-different-domain/</link><pubDate>Tue, 29 Mar 2016 16:42:56 -0400</pubDate><guid>https://am2.co/2016/03/29/uft-to-sql-server-conecction-which-is-located-at-different-domain/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133702/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I need to connect to a SQL Server through UFT (Unified Functional Testing) but the problem is SQL Server is present at different domain whereas QTP (HP QuickTest Professional) is present in a different domain. &lt;/p&gt;&#10;&lt;p&gt;I am able to connect to SQL Server manually from my domain using &lt;/p&gt;</description></item><item><title>After trying to restart moved database: Unable to open the physical file "D:\Data\MYDBNAME.MDF"</title><link>https://am2.co/2016/03/29/after-trying-to-restart-moved-database-unable-to-open-the-physical-file-ddatamydbname-mdf/</link><pubDate>Tue, 29 Mar 2016 13:01:56 -0400</pubDate><guid>https://am2.co/2016/03/29/after-trying-to-restart-moved-database-unable-to-open-the-physical-file-ddatamydbname-mdf/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133663/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;So the default location for databases on our server is &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10;c:\program files\microsoft sql server\mssql11.mssqlserver\mssql\DATA&#10;&lt;/div&gt;&#10;&lt;p&gt;but due to space limitations we instead use &lt;/p&gt;&#10;&lt;div class="errorMsg"&gt;&#10;d:\data&#10;&lt;/div&gt;&#10;&lt;p&gt;I have now since corrected the default location to be &lt;code&gt;d:\data&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;However I am unable to move a database that was created in the wrong location i.e. from &lt;code&gt;c:\...\data&lt;/code&gt; to &lt;code&gt;d:\data&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Why is the MSDB database TRUSTWORTHY?</title><link>https://am2.co/2016/03/24/why-is-the-msdb-database-trustworthy/</link><pubDate>Thu, 24 Mar 2016 20:38:35 -0400</pubDate><guid>https://am2.co/2016/03/24/why-is-the-msdb-database-trustworthy/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/133325/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;The &lt;code&gt;TRUSTWORTHY&lt;/code&gt; setting can be rather dangerous if you aren't careful and except for specific circumstances the recommendation is to keep it turned off. However by default the &lt;code&gt;MSDB&lt;/code&gt; database has &lt;code&gt;TRUSTWORHTY&lt;/code&gt; set &lt;code&gt;ON&lt;/code&gt; by default. I'm curious why?&lt;/p&gt;</description></item><item><title>some SQL Server MSX targets show as Normal, Blocked</title><link>https://am2.co/2012/03/27/some-sql-server-msx-targets-show-as-normal-blocked/</link><pubDate>Tue, 27 Mar 2012 12:19:30 -0400</pubDate><guid>https://am2.co/2012/03/27/some-sql-server-msx-targets-show-as-normal-blocked/</guid><description>&lt;p&gt;&lt;a href="https://dba.stackexchange.com/q/15681/52344"&gt;&lt;img src="https://am2.co/images/stack-exchange-question-mark.svg" alt="Question on Stack Exchange" width="96" height="96" class="stack-exchange-question-icon" /&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="question"&gt;Question&lt;/h2&gt;&#10;&lt;p&gt;I've centralized my farm's jobs in MSX, covering about 70 instances of SQL Server. Seemingly randomly, at least once a week, several instances will stop accepting instructions. Within the MSX window Manage Target Servers, instead of all instances showing as &lt;strong&gt;Normal&lt;/strong&gt;, they show as &lt;strong&gt;Normal, Blocked&lt;/strong&gt;. I have failed to figure out why this happens. Defecting and re-enlisting usually cures this ill, but that means having to re-add that target in any appropriate jobs, so I would rather resolve the cause than endure the workaround. &lt;/p&gt;</description></item></channel></rss>