Installing SQLCMD


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.

2 thoughts on “Installing SQLCMD

  1. deepak katika says:

    Hi Kenneth,

    Hope you are doing fine! I need help in setting up the sqlcmd.exe in windows 2016 server. I have setup the sqlps module and sqlserver modules. However I am getting the below error while executing the remote script using powershell

    ‘”sqlcmd -E -S “servername” -b -Q “sqlcmd’ is not recognized as an internal or external command,
    operable program or batch file.
    13:07:49 – Exit Code 1

    Can you suggest me a fix or troubleshooting steps to resolve this issue.


    Deepak katika

    • Generally I would recommend posting questions like these on a forum. I like and That said, I would check where sqlcmd is installed and where you are running it from. It may just not be in the path correctly.

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

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

Join 3,755 other subscribers

Follow me on Twitter

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