MS-SQL osql command
The MS-SQL server comes with the management console, which has several useful functions. One of which is the ability to send SQL queries to the database.
There is another utility that is installed with SQL server. It is the osql command line query utility. With the osql utility, you can send queries from the command prompt it Windows. While this may not seem to be very useful, there are a couple of instances where it is essential.
One place that I use the osql utility is to run the same SQL script on several different servers. When all of the target servers are available from a central location, they can be accessed via the osql utility. For example, they are all on the same physical LAN, or are accessible via VPN connections from a central location.
In this case, I setup a batch file, that steps through each server, and executes the osql script. Since osql has the ability to designate an output file, I also save the output to a file that is named based on the server name used. That way, I can review the output from each server.
The other place that osql is advantageous, is with SQL-SSE. Since there is no management utility with the SSE management console, tasks such as backup, and re-indexing, have to be scripted manually. Once the script is done, a batch file is created to run the script via the osql utility. This batch file can then be scheduled via the Windows system scheduling utility to automate these maintenance tasks.
I will cover the details of using osql in my next blog. Contact CCS Retail Support for assistance.
