Most Valuable Yak (Rob Volk) Blog

…and other neat SQL Server tricks

Command Line SQL Server

I've set up a new category on my blog where I plan to post some articles about using command-line utilities to perform various tasks for, or in support of, SQL Server. I'll go over the basics like bcp, osql, DOS commands, and hopefully go more in-depth on some other utilities from the Unix/Linux world that are incredibly useful. I'm hoping to even post a full case study where an existing monolithic, mission-critical VB app is replaced with command-line utilities (depends upon workload and office politics though) I won't post all of them in the main SQL Team blog page, so you should check the above link periodically if you're interested.

I've recently finished converting one small process from 140 lines of SQL down to about 30 combined lines of SQL and command-line scripting. I hope to have it written up over the weekend (1/16/05) so if you don't see it by then, make sure to harass me about it. :) And if you have any ideas, requests, or questions that you think might make a good topic please feel free to share. Worst case, you get a little free consulting.

Just a note, I'm going to use a standard admonition to "read the previous articles" for anything in this series of articles on command-line utilities. So if you see a "Part 2", "Part 3", "Part 18" and you don't remember reading the earlier parts, scroll down and read them first. :) Most of them will be cumulative.

Another note: I will be using the terms "DOS commands/prompt", "command-line/command prompt", and "Unix utilities" interchangeably. Regardless of the term, ALL of the utilities listed in this series are available for and will work on Windows platforms. Win2000, XP, and 2003 definitely, and perhaps even NT, WinME and Win98 too (I haven't tested them).

I should also point out that a command prompt can be utilized in Windows by using the Run... item on the Start menu, and putting "cmd" in the command box. cmd is the command-line interpreter for Windows.

Legacy Comments


Brett
2005-01-13
Suggestion
Well, what about article: More Trees and Hierarchies - Part II

Oh, wait, SQL 2005 is just around the corner. That should produce a different light on the subject.

Command Line Rules! How about a discussion of using command line with xp_cmdshell?


rockmoose
2005-02-02
Well done
This is really great stuff!
Having read the follow up articles on the for command I can only say that I am very impressed.

You have actually managed to write an article on dos and cli which is really interesting, helpful and fun to read!!!

Looking forward to any follow ups that mmay come.

ClaesW

Mr Chan
2005-07-12
re: Command Line SQL Server
How to using the command line to attach and detach SQL database

Thanks

kholmes@kml.kaba.com
2006-02-15
re: Command Line SQL Server
how to run sql from cmd
view version
select @@version

Markesh
2006-03-17
re: Command Line SQL Server
Good

deepak
2006-05-22
re: Command Line SQL Server
i want to teach which way we execute the sql cmmands in query analyser and which way we can create tables and database and what are the command lines of that pls give me the knowledge about that if any document is there which document can teach me pls allow me to download it