Installing SQLCMD

Leave a comment

October 19, 2016 by Kenneth Fisher

For anyone who wasn’t aware SQLCMD is a command line tool for running T-SQL statements and scripts. Before anyone says anything I want to point out that yes, I realize that you can use Powershell instead. Of course not all of us know Powershell all that well and most of us do know T-SQL. Until that changes (and I expect it will) SQLCMD (or some form of it) will be around.

What are some common uses for SQLCMD?

  • Run scripts on remote servers.
    SQLCMD can easily be used to run a script or stored procedure on a remote SQL Server. Combining this with a bat file (yes, again older technology) and an Enterprise scheduler (because not all of us use SQL Server Agent) can be a very powerful way to run T-SQL.
  • Connecting to the DAC
    The DAC (dedicated admin connection) is vitally important when you have problems with your SQL Server. It has its own dedicated resources and can be used even when no other connections may be able to do anything. SQLCMD is a light weight way of connecting and fixing your server.

 
SQLCMD is installed with SSMS and with the database engine. This means it’s going to be installed on the server where your instance is located and probably your workstation as well. However every now and again you want it installed on a machine where no SQL components are installed. Say an application server. It’s not overly difficult fortunately. You just download and install the Command Line Utilities for SQL Server.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 1,646 other followers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: