<?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 Brandon Pugh&#39;s Blog</title>
    <link>https://www.brandonpugh.com/tags/sql-server/</link>
    <description>Recent content in Sql-Server on Brandon Pugh&#39;s Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 06 Jun 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://www.brandonpugh.com/tags/sql-server/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Install SQL Server from the command line</title>
      <link>https://www.brandonpugh.com/til/sql-server/install-from-cli/</link>
      <pubDate>Fri, 06 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.brandonpugh.com/til/sql-server/install-from-cli/</guid>
      <description>&lt;p&gt;I recently had to setup a new windows dev machine with a local instance of SQL Server and it turns out you can run it completely from the command line although it&amp;rsquo;s not very obvious how.&lt;/p&gt;
&lt;p&gt;Once you &lt;a href=&#34;https://www.microsoft.com/en-us/sql-server/sql-server-downloads&#34;&gt;download the installer&lt;/a&gt; it will extract everything to a folder which contains the &lt;code&gt;SETUP.exe&lt;/code&gt; executable which you can run from the terminal and pass all the options you want instead of clicking through the UI.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re like me and just needed a fairly standard installation for local development, then this should do it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-powershell&#34; data-lang=&#34;powershell&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;.\&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;SETUP&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;py&#34;&gt;EXE&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;IACCEPTSQLSERVERLICENSETERMS&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ACTION&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;install&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;FEATURES&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;SQLEngine&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;FullText&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;INSTANCENAME&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;MSSQLSERVER&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;SQLSYSADMINACCOUNTS&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$env:USERDOMAIN&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;\&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$env:USERNAME&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;SQLSVCACCOUNT&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;NT Service\MSSQLSERVER&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;AGTSVCACCOUNT&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;NT Service\SQLSERVERAGENT&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;SQLSVCINSTANTFILEINIT&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;True&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;INDICATEPROGRESS&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Q&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Management studio is no longer included with the main installer but you can use winget: &lt;code&gt;winget install -e --id Microsoft.SQLServerManagementStudio&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If you need additional features then you need to &lt;a href=&#34;https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-ver17#Feature&#34;&gt;look up&lt;/a&gt; the options to set on the &lt;code&gt;/FEATURES&lt;/code&gt; param, like &lt;code&gt;RS&lt;/code&gt; for reporting services.&lt;/p&gt;
&lt;h2 id=&#34;details&#34;&gt;Details&lt;/h2&gt;
&lt;p&gt;This is what the above command does:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/IACCEPTSQLSERVERLICENSETERMS&lt;/code&gt; - Required to accept the SQL Server license terms.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/Q&lt;/code&gt; - Runs setup in &lt;strong&gt;quiet mode&lt;/strong&gt;. This is needed otherwise it will just open the regular install UI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/ACTION=&amp;quot;install&amp;quot;&lt;/code&gt; - Specify that we want to install vs uninstall or upgrade.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/FEATURES=SQLEngine,FullText&lt;/code&gt; - Specify which SQL Server components to install:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SQLEngine&lt;/strong&gt;: The core database engine&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;FullText&lt;/strong&gt;: Full-text search&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/INSTANCENAME=&amp;quot;MSSQLSERVER&amp;quot;&lt;/code&gt; - &lt;code&gt;&amp;quot;MSSQLSERVER&amp;quot;&lt;/code&gt; is the &lt;strong&gt;default instance name&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/SQLSYSADMINACCOUNTS=&amp;quot;$env:USERDOMAIN\$env:USERNAME&amp;quot;&lt;/code&gt; - Use powershell environment variables to set the current user as the sql server admin&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/SQLSVCACCOUNT=&amp;quot;NT Service\MSSQLSERVER&amp;quot;&lt;/code&gt; - Set the service account for the SQL Server Database Engine service. &lt;code&gt;&amp;quot;NT Service\MSSQLSERVER&amp;quot;&lt;/code&gt; is the common default when using the UI.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/AGTSVCACCOUNT=&amp;quot;NT Service\SQLSERVERAGENT&amp;quot;&lt;/code&gt; - Sets the account for the &lt;strong&gt;SQL Server Agent service&lt;/strong&gt; (handles scheduled jobs and alerts)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/SQLSVCINSTANTFILEINIT=True&lt;/code&gt; - Enables &lt;a href=&#34;https://learn.microsoft.com/en-us/sql/relational-databases/databases/database-instant-file-initialization&#34;&gt;&lt;strong&gt;Instant File Initialization&lt;/strong&gt;&lt;/a&gt;, which seems like a worthwhile performance optimization according to the docs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/INDICATEPROGRESS&lt;/code&gt; - Shows installation progress in the console window, useful for monitoring the installation status&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also, you can apparently install from a &lt;a href=&#34;https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-using-a-configuration-file?view=sql-server-ver17&amp;amp;source=recommendations&#34;&gt;configuration file&lt;/a&gt; that the installer can generate for you.&lt;/p&gt;

       &lt;hr&gt; &lt;p&gt;Thank you for keeping RSS alive. You&#39;re awesome.&lt;/p&gt; &lt;p&gt;&lt;a href=&#34;mailto:blogrss@bpugh.dev&#34;&gt;Reply by email&lt;/a&gt;&lt;/p&gt;
        &lt;img src=&quot;https://blog.bpugh.workers.dev/cdn/images?p=/til/sql-server/install-from-cli/feed&quot;&gt;
      </description>
    </item>
    
    <item>
      <title>Hide a table in sql server management studio</title>
      <link>https://www.brandonpugh.com/til/sql-server/system-table/</link>
      <pubDate>Thu, 06 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://www.brandonpugh.com/til/sql-server/system-table/</guid>
      <description>&lt;p&gt;Apparently in sql server you can mark any table as a system table using &lt;code&gt;EXEC sys.sp_MS_marksystemobject&lt;/code&gt; and then Management studio will hide it automatically.&lt;/p&gt;
&lt;p&gt;I ran into this because the docs say that Entity Framework 6 stores its code-first migration snapshots in a table called &lt;code&gt;__MigrationHistory&lt;/code&gt; but I couldn&amp;rsquo;t find it because it&amp;rsquo;s &lt;em&gt;hidden&lt;/em&gt; since it&amp;rsquo;s marked as a system table.&lt;/p&gt;

       &lt;hr&gt; &lt;p&gt;Thank you for keeping RSS alive. You&#39;re awesome.&lt;/p&gt; &lt;p&gt;&lt;a href=&#34;mailto:blogrss@bpugh.dev&#34;&gt;Reply by email&lt;/a&gt;&lt;/p&gt;
        &lt;img src=&quot;https://blog.bpugh.workers.dev/cdn/images?p=/til/sql-server/system-table/feed&quot;&gt;
      </description>
    </item>
    
    <item>
      <title>Use a table variable to hold a list of values</title>
      <link>https://www.brandonpugh.com/til/sql-server/table-variables/</link>
      <pubDate>Tue, 04 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://www.brandonpugh.com/til/sql-server/table-variables/</guid>
      <description>&lt;p&gt;You can store a &amp;ldquo;list&amp;rdquo; of values in sql with a &lt;code&gt;table&lt;/code&gt; variable.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;DECLARE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;@&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;listOfIDs&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;TABLE&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;id&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;INT&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;INSERT&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;INTO&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;@&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;listOfIDs&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;SELECT&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;id&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;FROM&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Transactions&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;WHERE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;USER&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;bob&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
       &lt;hr&gt; &lt;p&gt;Thank you for keeping RSS alive. You&#39;re awesome.&lt;/p&gt; &lt;p&gt;&lt;a href=&#34;mailto:blogrss@bpugh.dev&#34;&gt;Reply by email&lt;/a&gt;&lt;/p&gt;
        &lt;img src=&quot;https://blog.bpugh.workers.dev/cdn/images?p=/til/sql-server/table-variables/feed&quot;&gt;
      </description>
    </item>
    
  </channel>
</rss>