Microsoft SQL Server provides a tool to connect to the SQL Server database to run SQL queries all from the command line. This is useful for database administrators who need to quickly connect to run a SQL command without having to start the SQL Server Management Studio (SSMS).
In this example I will concentrate on 3 simple examples to give a quick overview of what you can do with SQLCMD. The first example shows you how to connect to a SQL Server database using the Windows Authentication. The second example shows you how to connect to SQL Server database using the SQL Authentication and finally the third example shows you how to run a simple SELECT query. All examples are based on SQL Server 2005.
Connect to the master database using Windows Authentication
-E indicates Windows Authentication.
-S the SQL Server name instance. In this example it is Merovingian.
-d name of the database. In this example the database is master.
Connect to the master database using SQL Authentication
-S the SQL Server name instance. In this example it is Merovingian.
-d name of the database. In this example the database is master.
-U the username used to login to SQL Server using SQL Authentication.
-P the password used to login to SQL Server using SQL Authentication.
SELECT query using SQLCMD
In this example, we want to query the TOP 10 contacts displaying the first name and last name.
Sphere: Related Content









There is also a free tool “SQLS*Plus” which is an SQL*Plus for SQL Server. Works with SQL Server 2000/2005 and 2008
Very flexible with data formatting (set lines size, pagesize, etc), variables (&, &&), etc – light years better than isql or sqlcmd
I found it at http://www.memfix.com