Microsoft SQL Server OSQL.exe Tool

Looking for a quick command line approach to accessing Microsoft SQL Server? 

With SQL Server 2005 there is a command line utility called OSQL.  This tool can be used to connect to a SQL Server database and perform various SQL commands at a command prompt.  The tool can be used to access SQL Server Express, Standard and Enterprise editions.

At the command prompt simply key in OSQL.exe followed by the login credentials.

Example:
OSQL.EXE -U <username> -P <password> -S <MachineName\SQLExpress>

This is a great tool for checking connectivity to a given database server or even doing some more complex things like creating or populating a database.  When working with SQL Server for MicroStation or ProjectWise it's a quick, convenient way to access the database without requiring SQL Server Management Studio to be installed.

Once connected just enter the SQL you want to execute followed by "GO".  To exit the utility just key in "exit" at the command prompt.

For more information on the OSQL Tool and a list of the command line options check out Microsoft's web site at the following link:

http://msdn.microsoft.com/en-us/library/aa213090(SQL.80).aspx