I've been trying to use the SQL Server Management Studio 2008's built in "Solution Explorer" to manage a project and after 2 weeks of struggling with it, I've decided I don't really care for it. It's "convenience" features are actually quite a hindrance.

Unfortunately, the place where I work is a MS shop, and is pretty stuck in their ways. I want to go back to the command line (I crave Vim!). I've installed a local subversion repository with a TortiseSVN front end, to replace the above mentioned "Solution Explorer" and have it running quite well. I have also installed Vim and while still working on customizing it, have it humming.

However, the one thing that I am yet to find a solution to is how to run commands to SQL Server via the command line. I'm used to MySQL/Postgres command line prompt since that is what I have used in the past and was using while going through my classes. However, I can't seem to find a way to execute my scripts via the command line in windows. I currently edit them in Vim, refresh the page in SSMS, and execute. I would prefer to not even touch SMSS unless needed.

I've seen posts suggesting sqlsharp, but when I went to the page, I get the feeling that isn't quite what I'm looking for.


I really wish that it was possible to have 2 answer check marks. P. Campbell has the technical right answer, and I've tried it a few times (I keep getting an error when I try sqlcmd... In researching that it's how named pipes is operating... Even though I have it set up and enabled, it doesn't seem to work.)

After trying that and not having any success, I tried the just copy and paste into Management studio method, but that was ridiculous... So I decided that maybe HardCode is correct too.


5 Answers 5


Have you considered SQLCMD?

Here's an article on Using the SQLCMD command line utility.

You can execute adhoc SQL statements, or run .sql scripts.

The following example runs the C:\MyScript.sql script from the command line and outputs the queries and results to a text file located at C:\MyResults.txt.

C:\Windows>sqlcmd -S NOTTINTRA3\SQL2005 -i C:\MyScript.sql -o c:\MyResults.txt -e

enter image description here


There is nothing wrong with opening Management Studio, clicking 'New Query', and just typing out T-SQL commands. You may be making it more complicated than necessary.

  • @HardCode I had a feeling that was the case. I've just used linux for so long that I'm going bonkers here. I don't mind MS and all (in fact, I've moved more middle ground since graduating) but I do find some of their tools, well, incomplete. The solution explorer isn't much of an option in my book, but Yeah, everthing else (vim and command line) are pretty much optional, makeing it hard for myself items. But, in the end, it's more of a curiosity thing then anything else. Thanks!
    – Antiparadigm
    Commented Feb 9, 2011 at 22:59

If you really crave vim, consider using sqlcmd and setting SQLCMDEDITOR=vim in your environment. Of course you need to install vim.

For full directions, look here


SQL Server ships with a number of command-line utilities. SQLCMD is the one that allows you to run T-SQL commands directly against a database. The MSDN page on the utilities is here, with jump-off links to each.

Regarding your postscript, you would still need a command-line database client of some kind, Linux-based, in this case. I have no idea if such a thing exists. Setting up a completely different platform just to manage a database with a different UI paradigm (assuming that's what you're suggesting) seems like... overkill, though. :)


Solution explorer sucks, plain and simple. And I consider the guys that wrong most of that crap good friends. Just create a folder (it has a nice one that it uses by default) and just save your stuff in there.

Not the answer you're looking for? Browse other questions tagged or ask your own question.