Microsoft has made SQL 2017 and later version available for MacOS and Linux system. This change has made possible to run SQL Server from a Docker container. There for no need to install a virtual machine with Windows.
Follow instruction described in below article to install MS-SQL on your Mac.
Step 3 – Restore sample database WideWorldImporters
- Copy backup file of WideWorldImporters https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0
- use docker exec to create a backup folder. The following command creates a /var/opt/mssql/backup directory inside the SQL Server container.
sudo docker exec -it MSSQLDB mkdir /var/opt/mssql/backup
- Use docker cp to copy the backup file into the container in the /var/opt/mssql/backup directory.
- Use below command in SQL Client to list database files –
restore FILELISTONLY FROM disk = '/var/opt/mssql/backup/WideWorldImporters-Full.bak'
- Use below command to restore database
RESTORE DATABASE WideWorldImporters FROM DISK = '/var/opt/mssql/backup/WideWorldImporters-Full.bak' WITH MOVE 'WWI_Primary' TO '/var/opt/mssql/data/WideWorldImporters.mdf', MOVE 'WWI_UserData' TO '/var/opt/mssql/data/WideWorldImporters_userdata.ndf', MOVE 'WWI_Log' TO '/var/opt/mssql/data/WideWorldImporters.ldf', MOVE 'WWI_InMemory_Data_1' TO '/var/opt/mssql/data/WideWorldImporters_InMemory_Data_1'
- Run query against database