We have some legacy .bat scripts full of osql commands to existing SQL Server instances / dbs on our network.

We've tried running the .bat scripts from our app server (Win Server 2008) but get the error: "osql.exe' is not recognized as an internal or external command"

We are hoping we don't need to install a full-blown SQL Server to get access to osql.

I've heard you can get it from the Client Tool installation, and no license required as long as connecting to licensed sql servers. (which we would be).

Can anyone confirm? Are "Client Tools" part of the installation discs?
Is this a viable solution?

Thanks for your help folks!

  • OSQL.EXE is installed when you install SQL Server Management Studio (version 17.5)
    – ThePeter
    Mar 8, 2018 at 19:23
  • If OSQL/SQL Server is recently installed, ensure command prompt (cmd.exe) is reopened. Otherwise, the PATH may not be updated.
    – Ivan Chau
    Nov 26, 2019 at 7:13

3 Answers 3


The main recommendations appear to be:

  • If you have the install discs / files, then you should be able to install just the Client Tools.

  • Download SQL Server 2012 (SP1) Express (I would try the "SQL Server Management Studio Express (Tools only)" version first)

  • Check out: http://www.mssqltips.com/sqlservertip/1807/sql-server-2008-client-tools-installation/

  • If you already have a machine with OSQL installed, you might be able to copy just the following two files to the new server (place them in the same directory) and have it work:

    • C:\Program Files\Microsoft SQL Server\110\Tools\Binn\OSQL.EXE
    • C:\Program Files\Microsoft SQL Server\110\Tools\Binn\Resources\1033\osql.rll

As far as licensing goes, I found the following file:

C:\Program Files\Microsoft SQL Server\110\Tools\Binn\Resources\1033\license_SQLCMD.txt

That has the following snippet:

1. INSTALLATION AND USE RIGHTS. You may install and use any number of copies of the software on your devices to design, develop and test your programs.

OSQL has been superseded by SQLCMD. When you run OSQL it will display the following message:

Note: osql does not support all features of SQL Server 2012. Use sqlcmd instead. See SQL Server Books Online for details.

However, if your existing code expects OSQL then you would need to test SQLCMD with your code first to make sure that any behavior changes between OSQL and SQLCMD do not break your code.

  • Thanks for the feedback - will give install discs a shot. That might sound obvious, but that actually will take me a request to a different team. I'm sure you can appreciate why I was inquiring on right approach. No matter where I go, it will likely involve a different servicing team within our org.
    – knuckle05
    Apr 13, 2014 at 4:57
  • 1
    Since 2012 SP1 Express (download here), SQL Server Management Studio (SQLManagementStudio_x64_ENU.exe) is now a complete version rather than a feature-limited version of what you'd see in other editions. I'm not sure it includes osql (though I suspect it does), but I'd always recommend grabbing the SP1 installer over the original 2012 version. Apr 13, 2014 at 16:16
  • @knuckle05: You might not need the install discs. I just updated my answer with the idea of copying just the 2 relevant files. I tried it on my system and it worked so it is worth testing on your end as it does simplify things a bit. Apr 13, 2014 at 19:37
  • @NathanJolly: Thanks! I have updated my answer with that link. Apr 13, 2014 at 19:43
  • The text snippet about licensing is about "design, develop and test" of programs so it is not relevant for this post.
    – miracle173
    Aug 12, 2014 at 10:14

The tool you should be using is sqlcmd. It is installed with the client tools and replaces the deprecated osql.


This worked for me based on the tips provided:

  1. I copied osql.exe and dropped it into the C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn folder
  2. C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn was already assigned to the environment variable PATH

I was then able to run my batch file which required osql.exe. Note the version of osql.exe that I copied is very old (November 1998)

So thank you for providing useful information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.