If you’re like me, and is tying to follow a tutorial about SQL which is using Adventureworks on Mac… or just simply wanna play with a good sample DB. Here’s a step by step guide on how to set it up.

Prerequisites

Run SQL Server

Pull SQL Server

sudo docker pull mcr.microsoft.com/mssql/server:2017-latest

Run SQL Server locally.

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>"  -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest

See running containers

docker ps

image

You now have a SQL Server running locally

Connect to your SQL Server using Azure Data Studio

  • Click on New Connection image or if you’ve used it before, under Connections, next to SERVERS, click the New Connection Icon image

  • Fill it in:

    • Server: localhost
    • Username: sa
    • Password: (what you put in YourStrong@Passw0rd) above when you ran the docker container image

Import AdventureWorks.bak

  • Download AdventureWorks2017.bak (or whatever year) from
  • Copy it over to your docker container

    • Check your container ID and copy over your file into the mssql directory in the container. In this case, my file saved in my ~/Downloads directory
    docker ps
    docker cp ~/Downloads/AdventureWorks2017.bak <containerID>:/var/opt/mssql/data/
    
  • Back to Azure Data Studios, click on your localhost connection, and click Restore in the Dashboard image

  • In General > Source. Select Restore from: Backup file. And in Backup file path, click (…) image

  • You should be able to see AdventureWorks under data image

  • Hit Restore

  • You now should be able to see your AdventureWorks db under Databases. If not, right click on Databases and click “Refresh”. image

  • You can click on the AdventureWorks DB and click New Query on the dashboard image

Happy Learning!