<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ mssql - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ mssql - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Thu, 09 Jul 2026 20:25:40 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/mssql-3/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Connect your Microsoft SQL Server Docker Container with Azure Data Studio ]]>
                </title>
                <description>
                    <![CDATA[ By Clark Jason Ngo This guide shows you how to use Docker to pull a MSSQL Server image and run it. Azure Data Studio is a cross-platform database tool that will be using to connect our Docker container with MSSQL and execute SQL statements.  At the e... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/cjn-how-to-connect-your-microsoft-sql-server-docker-container-with-azure-data-studio/</link>
                <guid isPermaLink="false">66d45e0cf855545810e93427</guid>
                
                    <category>
                        <![CDATA[ mssql ]]>
                    </category>
                
                    <category>
                        <![CDATA[ database ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ docker image ]]>
                    </category>
                
                    <category>
                        <![CDATA[ SQL ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 29 Mar 2020 11:22:53 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/Screen-Shot-2020-03-29-at-3.52.47-AM.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Clark Jason Ngo</p>
<p>This guide shows you how to use Docker to pull a MSSQL Server image and run it. Azure Data Studio is a cross-platform database tool that will be using to connect our Docker container with MSSQL and execute SQL statements. </p>
<p>At the end, I will show you how to import a database to the Docker file system so that you can access it through Azure Data Studio.</p>
<p>Check out other related guides here:</p>
<ul>
<li><em><a target="_blank" href="https://www.freecodecamp.org/news/cjn-how-to-connect-your-aws-rds-microsoft-sql-server-using-azure-data-studio/">How to Connect your AWS RDS Microsoft SQL Server using Azure Data Studio</a></em></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/cjn-how-to-import-a-sample-database-to-your-aws-rds-microsoft-sql-server-using-s3/"><em>How to Import a Sample Database to your AWS RDS Microsoft SQL Server using S3</em></a></li>
</ul>
<p>We will be touching on the technologies shown below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-238.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Database: Microsoft SQL Server</li>
<li>Container to pull mssql-server-demo: Docker</li>
<li>Installer for mssql-cli: Node.js (Run-time Environment) / Node Package Manager (NPM)</li>
<li>Database tool and GUI: Azure Data Studio</li>
</ul>
<h2 id="heading-building-our-environment-with-docker">Building our Environment with Docker</h2>
<h3 id="heading-installing-docker">Installing Docker</h3>
<p>Full guide for this portion <a target="_blank" href="https://database.guide/how-to-install-sql-server-on-a-mac/">here</a>: </p>
<ol>
<li>Download Docker CE (Community Edition) for Mac <a target="_blank" href="https://store.docker.com/editions/community/docker-ce-desktop-mac?tab=description">here</a>.</li>
<li>To install, double-click on the .dmg file and then drag the Docker application icon to your Application folder.</li>
</ol>
<h4 id="heading-what-is-docker">What is Docker?</h4>
<p>Docker is a platform that enables software to run in its own isolated environment. SQL Server (from 2017) can be run on Docker in its own isolated container. </p>
<p>Once Docker is installed, you simply download — or “pull” — the SQL Server on Linux Docker Image to your Mac, then run it as a Docker container. This container is an isolated environment that contains everything SQL Server needs to run.</p>
<h3 id="heading-launch-docker">Launch Docker</h3>
<p>Open your Docker application, it should be located in the Applications folder.</p>
<h3 id="heading-increase-the-memory">Increase the Memory</h3>
<p>By default, Docker will have 2GB of memory allocated to it. SQL Server needs at least 3.25GB. To be safe, increase it to 4GB if you can. Since this is just a playground, 2GB should be enough.</p>
<h3 id="heading-optional-in-case-you-want-to-increase-memory-size">Optional - in case you want to increase memory size:</h3>
<ol>
<li>Select Preferences from the little Docker icon in the top menu</li>
<li>Slide the memory slider up to at least 2GB</li>
<li>Click Apply &amp; Restart</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-245.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-246.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-download-sql-server">Download SQL Server</h3>
<p>Open a Terminal window and run the following command.</p>
<pre><code class="lang-terminal">sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
</code></pre>
<p>This downloads the latest SQL Server 2019 for Linux Docker image to your computer.</p>
<p>You can also check for the <a target="_blank" href="https://hub.docker.com/_/microsoft-mssql-server">latest container version</a> on the Docker website if you wish.</p>
<h3 id="heading-launch-docker-image">Launch Docker Image</h3>
<p>Run the following command to launch an instance of the Docker image you just downloaded:</p>
<pre><code class="lang-terminal">docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=really
</code></pre>
<p>Example output:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-254.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-check-the-docker-container-optional">Check the Docker container (optional)</h3>
<p>You can type the following command to check that the Docker container is running.</p>
<pre><code class="lang-terminal">docker ps
</code></pre>
<p>If it’s up and running, it should return something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-247.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you accidentally closed your Docker App, open your terminal and type</p>
<pre><code class="lang-terminal">docker start sql_server_demo
</code></pre>
<h3 id="heading-install-the-nodejs-and-npm">Install the Node.js and NPM</h3>
<p>Check if you have Node.js and NPM. Run the following commands in your terminal.</p>
<pre><code class="lang-terminal">node -v
npm -v
</code></pre>
<p>If you get an output with a version number, skip the rest of this section.</p>
<p>Then visit the Node.js website by clicking the following link:</p>
<p><a target="_blank" href="https://nodejs.org/en/">https://nodejs.org/en/</a></p>
<p>Click the LTS version (the version number may be various) download button to download the Node.js package:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-249.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Next click and run the package after downloading. MacOS and Windows will have different installation process. Please follow the instruction to install the Node.js.</p>
<p>Then test again if Node.js and NPM were installed successfully by running the following commands in the terminal:</p>
<pre><code class="lang-terminal">node -v
npm -v
</code></pre>
<p>An output should look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-248.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>#### </p>
<h3 id="heading-install-sql-cli">Install sql-cli</h3>
<p>Run the following command to install the sql-cli command line tool. This tool allows you to run queries and other commands against your SQL Server instance.</p>
<pre><code class="lang-terminal">npm install -g sql-cli
</code></pre>
<p>If you get a permission error, use the <code>sudo</code> command:</p>
<pre><code class="lang-terminal">sudo npm install -g sql-cli
</code></pre>
<p>### </p>
<h2 id="heading-connect-to-mssql-server">Connect to MSSQL Server</h2>
<p>Connect to your SQL Server using the mssql command, followed by the username and password parameters. Syntax: -u  -p </p>
<pre><code class="lang-terminal">mssql -u sa -p reallyStrongPwd123
</code></pre>
<p>Your output should look like this if you successfully connected:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-250.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-run-a-quick-test">Run a Quick Test</h3>
<p>Run a quick test to check if you can connect to your SQL Server. Use the following SQL statement to check your SQL Server version:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> @@<span class="hljs-keyword">VERSION</span>;
</code></pre>
<p>If it’s running, you should see something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-251.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-download-an-sql-server-gui-azure-data-studio">Download an SQL Server GUI - Azure Data Studio</h2>
<p><a target="_blank" href="https://database.guide/what-is-azure-data-studio/">Azure Data Studio</a> (formerly SQL Operations Studio) is a free GUI management tool that you can use to manage SQL Server on your computer. You can use it to create and manage databases, write queries, backup and restore databases, and more.</p>
<p>Azure Data Studio is available on Windows, Mac and Linux.</p>
<h3 id="heading-install-azure-data-studio">Install Azure Data Studio</h3>
<p>To install Azure Data Studio onto your Mac:</p>
<ol>
<li>Visit the <a target="_blank" href="https://docs.microsoft.com/en-us/sql/azure-data-studio/download">Azure Data Studio download page</a>, and click the .zip file for macOS</li>
<li>Once the .zip file has finished downloading, double click it to expand its contents</li>
<li>Drag the .app file to the Applications folder (the file will probably be called <em>Azure Data Studio.app</em>)</li>
</ol>
<h3 id="heading-connect-to-sql-server">Connect to SQL Server</h3>
<p>Now that Azure Data Studio is installed, you can use it to connect to SQL Server.</p>
<ol>
<li>Launch Azure Data Studio. It is located in your Applications folder.</li>
<li>Enter the login credentials and other information for the SQL Server instance that you’d like to connect to:</li>
</ol>
<p>It should look similar to this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-259.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>It should look similar to this:</p>
<ul>
<li><strong>Server Name</strong>: localhost, [port number]<br><strong>Example</strong>: localhost, 1433</li>
<li><strong>Authentication Type</strong>: SQL Login</li>
<li><strong>User name</strong>: [your SQL Server username] or sa</li>
<li><strong>Password</strong>: [your SQL Server password] or reallyStrongPwd123</li>
<li><strong>Database Name</strong>: </li>
<li><strong>Server Group</strong>: </li>
</ul>
<p>If you use a port other than the default 1433, click Advanced and enter it in the Port field.</p>
<p>Alternatively, you can append it to your server name with a comma in between. For example, if you used port 1400, type in localhost,1400.</p>
<p>You can now go ahead and create databases, run scripts, and perform other SQL Server management tasks.</p>
<ol>
<li>Click <strong>New Query</strong></li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-253.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ol start="2">
<li>Type <strong>SELECT @@VERSION</strong>, then Click <strong>Run Query</strong>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-241.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You should be able to see: <em>Microsoft SQL Server</em> in the Results.</p>
<h2 id="heading-importing-a-sample-database-to-your-sql-server-using-azure-data-studio">Importing a sample database to your SQL Server using Azure Data Studio</h2>
<h3 id="heading-download-the-sample-database-file-adventureworks">Download the sample database file AdventureWorks</h3>
<p>To get the OLTP downloads of AdventureWorks, go to this <a target="_blank" href="https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver15">link</a> and choose any sample database. In my example, I choose <code>AdventureWorks2017.bak</code>. We will upload this to the S3 Bucket.</p>
<h3 id="heading-copying-the-file-to-your-docker">Copying the file to your docker</h3>
<p>Type the following command in the terminal following this syntax:</p>
<pre><code>docker cp &lt;location_of_file&gt; <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">container_id</span>&gt;</span>:/var/opt/mssql/data</span>
</code></pre><p>It should look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-255.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you forgot your container id, use the <code>docker ps</code> command.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-258.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-importing-the-sample-database-in-docker">Importing the sample database in Docker</h3>
<p>Go to Azure Data Studio, and click the <strong>localhost, 1443</strong>, then choose <strong>Restore</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-265.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Then choose <strong>Backup file</strong> as the selection for <em>Restore from</em>. Next, click the blue button on the right of <em>Backup file path.</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-264.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Look for the sample database file. It should be located in </p>
<pre><code class="lang-terminal">/var/opt/mssql/data/AdventureWorks2017.bak
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-260.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Choose <strong>Restore</strong>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-263.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Check your localhost, 1443. It should generated a Database named AdventureWorks2017 and have contents such as Tables and Views. If not, right-click on localhost, 1443 and choose Refresh. You can also restart your Azure Data Studio application. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-262.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-testing-the-sample-database">Testing the sample database</h3>
<ol>
<li>Choose <strong>AdventureWorks2017</strong> from the dropdown menu.</li>
<li>Write a SQL query:</li>
</ol>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> HumanResources.Department;
</code></pre>
<ol start="3">
<li>Click <strong>Run</strong> to run the query.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-266.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You should have an output like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-267.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Congratulations! ???</p>
<p>Resources:</p>
<ul>
<li><a target="_blank" href="https://database.guide/how-to-install-sql-server-on-a-mac/">How to Install SQL Server on a Mac</a></li>
</ul>
<p>Connect with me on LinkedIn <a target="_blank" href="https://www.linkedin.com/in/clarkngo/">here</a></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/image-240.png" alt="Image" width="600" height="400" loading="lazy"></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
