Friday, March 12

Using MS SQL from Linux

As a programmer who works primarily on Linux machines, both on the desktop and server, I have found the number of free clients for SQL Server to be sparse at best.  There are a few... Squirrel SQL comes to mind as one.  Oracle SQL Developer works as well.  However, each of them have their difficulties.  I have had weird crashes with Squirrel and I can't use any of the advanced features in SQL Developer.  Such is the life of a linux based developer trying to work with the world of Windows.

One bright spot I discovered recently is SQSH.  It is essentially a shell for SQL Server that operates something like the shells for mysql or oracle that I am familiar with.  Why is that exciting at all you ask?  Ever tried to step through a large result set on the console?

The answer is, it's not so much the SQL part that is exciting, it's the shell part.  It's a real shell that goes beyond what is available in any of the other shells I am aware of.  Sure Oracle's SQLPlus will allow you to do variable substitution and some macros, but it's not nearly as powerful as sqsh.  In addition, you can use pipes!  That means, as I alluded to earlier,  you can step through large result sets by piping the output of a query to less just like you would in a linux or unix console.

You get flow control and even backgrounding.  So if you know a query is going to take a while, you can add an & to the end just like you would in a Linux shell and it will run in the background.

Here are all the features.  Even more awesome is the fact that it can be installed via apt-get on Ubuntu.  There is some extra setup required to make available the data sources you connect to, but it is very easy to get going quickly.

Just another tool for your developer toolbox.

No comments: