Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

--edit

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... Eventhough 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 rediculous... So I decided that maybe HardCode is correct too.

share|improve this question

migrated from stackoverflow.com Jul 3 '11 at 8:50

This question came from our site for professional and enthusiast programmers.

3  
Are you looking for the sqlcmd Utility? –  Joe Stefanelli Feb 9 '11 at 22:31
add comment

5 Answers

up vote 13 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
    
@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 Feb 9 '11 at 22:59
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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. :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.