Cross Platform CLI for SQL Server

I’m dying to get client software to access my SQL Server from my Mac. All this time I use Navicat for SQL Server Lite, as name, a lite/free version, which has been very outdated. The full version is more up-to-date and more features, but honestly it is a bit expensive for me.

Another option is using SQuirrel SQL which happens to have SQL Server support. Since it’s developed in Java and as long as you have JDBC driver of DBMS to access, I think it can access that DBMS well. It’s a great piece of free software. Just sometime it’s a bit complex for simple query operation that I want, for example.

Browsing around, I found this awesome project: SQL-CLI, a cross platform CLI for SQL Server. It’s developed in Node.js, so ideally if you can install Node.js in your machine in any OSes, you can install this tool, hence cross platform.

Let’s play around with it. Before we start, I don’t need to remind you that you need Node.js installed and run well in your machine. SQL-CLI doesn’t specify specific Node.js version so latest version will be good. I’m using Mac machine and Node.js┬áv0.10.25.

Installation is as simple as opening Terminal in your OSX and type this command:

After 1 or so minutes (depends on internet connection), it will be installed globally, meaning you can execute it anywhere from Terminal.

Connect

Make sure to change: server name, username and password with your own. You’ll get:

On

prompt, you can type commands or directly SQL Server’s T-SQL.

Let’s try by querying databases list accessible by current user:

Neat! Now, try to use one database, and show tables list:

Awesome!
Last, let’s try to type a T-SQL query:

When in doubt, always type:

To quit, well just type:

Last but certainly not least, if you have Azure CLI installed, you can integrate SQL-CLI that allows you to connect directly to SQL Server database of your Mobile Services account. To do that, just type:

That’s it, enjoy!