Sql Server Studio For Mac

  1. Sql Server Studio For Mac
  2. Sql Server Studio Express
  3. Sql Server Management Studio For Mac Download
  4. Sql Server Visual Studio For Mac
  5. Sql Server Studio Free Download

Mac SQL Studio aims to be a lightweight, multiple-database client and SQL (and NoSQL with HBase) development suite. It is written in pure Objective-C using the Cocoa Framework. The lightweight, cross-platform offering combines functionality found in tools like SQL Server Management Studio and the Visual Studio Code editor in order to help data developers and operations pros work with SQL Server, Azure SQL Database and Azure SQL Data Warehouse on Windows, Mac or Linux machines.

(Be sure to checkout the FREE SQLpassion Performance Tuning Training Plan - you get a weekly email packed with all the essential knowledge you need to know about performance tuning on SQL Server.)

Years ago when I switched from Windows to Mac, people have told me regularily that I’m crazy. How can I be that stupid to work on MacOS when I’m dependent on SQL Server? In my case it wasn’t that terrible, because my main work is about content creation (writing blog postings, articles, presentations, training videos) and very often I was only connecting through a RDP connection to a remote SQL Server. Therefore running natively on MacOS was not a big deal for me, and for the last resort I always have a Windows VM which runs in VMware Fusion on my Mac.

But since the introduction of the Container concept through Docker and the possibility to run SQL Server directly in a Container, my life was changing even better. Because now I can run SQL Server 2017+ directly on my Mac and I even don’t really need a Windows VM anymore. In this blog posting I want to show you how you can do the same and run SQL Server directly on your Mac in a Docker container.

Installing SQL Server in a Docker Container

Before you can install SQL Server in a Docker Container on the Mac, you have to install and configure of course Docker itself. I don’t want to go into the details how to install Docker itself, because the necessary steps are very well documented.

Before you can create a Docker Container for SQL Server, you have to pull the correct Docker Image from the Docker Registry. In my case I have decided to try out the latest CTP version of SQL Server 2019:

docker pull mcr.microsoft.com/mssql/server:2019-CTP2.1-ubuntu

When you have pulled the image, you can see it with the docker images command in your Terminal:

You can think about a Docker Image like an ISO file: it’s just an image, and you can’t run it directly, because you have to install it. Therefore we also have to “install” the pulled Docker Image. In Docker you can “install” an image by running it. And that creates the actual Docker Container, which is finally the exectuable that you are executing. Let’s run our Docker Image with the docker run command:

docker run -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=passw0rd1!’ -p 1433:1433 –name sql2019_ctp2 -d mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu

As you can see from the command line, you have to pass in a lot of different parameters. Let’s have a more detailed look on them:

  • -e ‘ACCEPT_EULA=Y’
    • With the -e option you set an environment variable, on which SQL Server is dependent on. In our case we have to accept the EULA to be able to use SQL Server.
  • -e ‘SA_PASSWORD=passw0rd1!‘
    • With the SA_PASSWORD environment variable we set the password for the SA login.
  • -p 1433:1433
    • With the -p option we bind a port on our host machine (in my case on the Mac) to a port in the Container. The port on the left side of the colon is the port on the host machine, and the port on the right side of the colon is the port in the Container. In my case I bind the default SQL Server port of 1433 within the Container to the port 1433 on my Mac.
    • Therefore I can directly access the exposed SQL Server Container through the IP address of my Mac on the network. If you have multiple SQL Server Containers, you can also bind them to different ports on your host machine to access them independently from each other.
  • –name
    • With the –name option we assign a custom name to our Docker Container.
  • -d
    • And with the -d option we specify the Docker Image that we have pulled previously, and that you want to run the Docker Container detached from the Terminal. This just means that you can close your Terminal, and your Docker Container is still running in the background.

After you have executed that Docker command, your Docker Container is up and running.

Accessing SQL Server on a Mac

We have now 2019 up and running in a Docker Container. But how do we access SQL Server? Of course, I can start up a Windows VM, and use SQL Server Management Studio to access SQL Server. But then I’m again dependent on a Windows VM, which also needs periodically updates, and it would be also a huge overhead to deploy a whole Windows VM just for SQL Server Management Studio…

Therefore let’s introduce Azure Data Studio! Azure Data Studio was formerly known as SQL Operations Studio and it is a client application with which you can manage SQL Server – natively on Windows, Linux, and Mac!!!

As you can see from the previous picture, I have connected here directly to localhost, because in the last step we have exposed the port 1433 of the Docker Container to our host machine. Don’t get me wrong: compared to SQL Server Management Studio, Azure Data Studio is “nice” but… 😉

But hey, I can run it directly on my Mac (without the need of a Windows VM), I can run SQL statements, I have access to Estimated and Actual Execution Plans, and very importantly – it’s extensible. What do I need more? For the kind of work that I’m doing, it’s enough.

Restoring your first Database

Sql Server Studio For Mac

When you look back to the previous picture, you can see that you got a vanilla installation of SQL Server 2019. There are our system databases, the crazy default settings, and that’s it. There are of course currently no other database. So you have to create your own databases, or you take an existing database (maybe from a Windows-based SQL Server installation) and you restore it in your Docker Container. Let’s do that now.

In my case I want to show you now the necessary steps how to restore AdventureWorks in the Docker Container. First of all you have to copy your backup file into the Docker Container. But you can’t do a regular cp command from the Terminal, because that command has no idea about your Docker Container. Makes somehow sense…

Therefore your Docker installation offers you the command cp with which you can copy a local file into a Docker Container and vice versa. Let’s take now our backup of AdventureWorks and copy it into the folder /var/backups of our Docker Container:

docker cp AdventureWorks2014.bak sql2019_ctp2:/var/backups/AdventureWorks2014.bak

After you have copied the backup file, we can now restore the database. But the destination folders are different as on a Windows-based SQL Server installation, therefore we also have to move our data and log files. Therefore I have executed in the first step the following command to get the logical file names of our database backup.

RESTORE FILELISTONLY FROM DISK = ‘/var/backups/AdventureWorks2014.bak’

And based on that information, let’s perform now the restore of our database.

For

RESTORE DATABASE AdventureWorks2014 FROM DISK = ‘/var/backups/AdventureWorks2014.bak’

WITH

MOVE ‘AdventureWorks2014_Data’ TO ‘/var/opt/mssql/data/Adventureworks2014.mdf’,

Sql Server Studio Express

MOVE ‘AdventureWorks2014_Log’ TO ‘/var/opt/mssql/data/Adventureworks2014.ldf’

As you can see I’m moving the data and log files into the folder /var/opt/mssql/data. And now we have our AdventureWorks database restored in our Docker Container.

When you are finished with your work in your Docker Container, you can stop the Container with the following command:

docker stop sql2019_ctp2

And with a docker start command, you can restart your Container again:

docker start sql2019_ctp2

In that case, all the changes that you have done in your Docker Container (like restoring the AdventureWorks database), are persisted across restarts.

Summary

Running SQL Server natively on a Mac or on Linux was always a huge April fool. But with the introduction of Docker, and the SQL Server support for it, it’s now real. You can now run natively SQL Server on the Mac, and with the help of Azure Data Studio you can even access SQL Server with a native MacOS application. We have really exiting times ahead of us!

Thanks for your time,

-Klaus

Just last year I got my first Macbook Pro for development, after a lifetime of Windows (and linux/unix on server environments). I was very excited to get my environment set up as many friends who work in a similar field had sworn by it. I knew that almost every element of my workspace would be easily transferrable to OSX, and in some cases more elegantly. Technologies such as Apache, PHP, ssh/shell, etc are almost more native to the *nix core than they are to windows.

There was however a single piece of the puzzle that I knew I still had to deal with. Microsoft SQL Server. My work use it, personally I woudln’t choose it for my own projects at all, I’d choose something less platform dependent. Having said that I actually don’t mind the product OTHER than it’s requirement to be run on Windows. It is a decent product, it’s professionally supported, and most of the clients in my industry use it. In fact not so long ago some may argue that it was one of the best choices for large systems. It was FAR superior to the well known MySQL and a lot more affordable than Oracle. Let’s not forget it was originally bought from Sybase (which is probably why the product isn’t all that bad! Microsoft didn’t create it!)

So basically I needed to use MS SQL Server. I have a seperate windows box with an SQL Server instance on it, and what I needed was a client program that could connect to the server so I could query it, write SQL, interrogate data etc. I needed the equivalent of Microsofts SQL Management Studio (which used to be called “Query Analyzer”), or “MySQL Workbench“.

One option of course was to install VMWare, install Windows, install Microsoft SQL Server and just use Microsofts native client. But I really didn’t want to do that. So after much reading & researching I narrowed my options down to a few potential candidates:

So I tried all these products, and here’s the problem. They’re ugly. They’re clunky, awkward and … ugly. Most likely because they’re Java based – but they’re just hideous. When you get used to an environment like MS SQL Server, you just can’t revert back to this kind of rubbish. It’s funny you know, when you research this stuff, you see a lot of people recommending these products. And after using them you immediately realise that these people either a) come from an old school linux or java background where everything is ugly and they’re used to it, b) they’ve never worked with large or complicated datasets where EFFICIENCY is of utmost importance and probably consider phpMyAdmin suitable for data wrangling.

But the problem is they’re not ok. I’m sorry, they’re just not. They’re unpolished. There are real annoyances – the forms are hideous. The result set grids will have 10px padding so you can only see about 5 rows of result sets, or the result set grids cells don’t automatically resize to the width of the content within the cell (within reason) – they just don’t cut it. It’s situations like this when you realise the word ‘enterprise’ actually does have a meaning beyond just being a buzzword!

I was about to lose hope then all of a sudden, another contender crossed my path:

It was beautiful – I was in love. It’s a completely professional, sexy, clean, efficient, enterprise grade, high end. powerful SQL interface. It’s actually quite close to Microsoft’s native client in feel. I got it all hooked up, everything was working well, I even connected over mmy SSH tunnels to remote clients (an article on that later). It was all looking good until I ran into a problem. Running some stored procedures gave an error.

Sql Server Management Studio For Mac Download

It turns out that SQL Developer is fine with standard SQL like SELECT, INSERT, UPDATE, DELETE etc, but when running certain SQL Server specific commands, SQL Developer doesn’t know how to interpret it, or interprets it correctly. A common problem seems to be the BEGIN and END keywords. It also can’t handle multiple resultsets returned from a stored procedure, and won’t handle the “go” command in SQL Server scripts.

Sql Server Visual Studio For Mac

So unfortunately in the end I installed Windows XP (for it’s light weight), MS SQL Server and just use the native Microsoft SQL Management Studio. Given that my brand new Macbook Pro handles this without struggling it’s actually a fairly reasonable solution, but I cross my fingers that one day Oracle SQL Developer is completely compatible, or that someone makes a worthwhile GUI.

It’s worth mentioning that if you do fairly straight forward queries without very large datasets or without complex SQL, some of the above products may well be suitable for you, I’m happy to answer any questions you may have in the comments.

Sql Server Studio Free Download

Edit (6th Jan 2015): It looks like some developers by the name of Hankinsoft ran into the same issue as many of us and have actually gone ahead and developed an MS SQL Client for Mac to address this very issue. The product is called SQLPro for MSSQL and although I’ve only recently started using it, I have to say so far it’s very impressive. It’s polished and pleasing-to-the-eye with it’s native Mac App design & feel, but at the same time is fast, responsive, efficient and dedicated to the task. It’s described as ‘lightweight’ and that’s what I love about it – so far, it’s handled everything I’ve thrown at it (including cross database joins etc), but isn’t overloaded with unnecessary features/preferences/bloating. So far I definitely recommend it.