Sql-server – get OSQL if I install SQL Server Client Tools

sql serversqlcmd

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!

Best Answer

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:

MICROSOFT SOFTWARE LICENSE TERMS MICROSOFT SQL SERVER 2012 COMMAND LINE UTILITIES
...
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.

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