Using the SQLCMD in SQL 2005 Server - SQL Client Connections
(Page 4 of 5 )
Close out of the SQL Server Network Connections, click on the SQL Client Configuration and expand the node to reveal the TCP node in the right pane. Right click on the TCP node to reveal the properties as shown in the next picture. You will see that the port it is listening to is different; it is 1433. Change this to 1037. Click on the button Apply and then click Ok. Close out of the configuration tool.

Did it fix the problem?
Go back to the DOS screen and run the SQLCMD command again. You will see that you are rocking now. Both OSQL and SQLCMD will work, the former implemented for backward compatibility with legacy scripts. They in no way interfere with one another. When SQLCMD is invoked from the command line it accesses the server via OleDB, whereas when it is invoked in the SQL Server Management Studio, it uses the .NET SQL Client.
C:Program FilesMicrosoft SQL Server90Shared>sqlcmd
1> exit
C:Program FilesMicrosoft SQL Server90Shared>osql
Error: No user selected. Try with -U or -E switches
C:Program FilesMicrosoft SQL Server90Shared>osql -E
1>
SQLCMD command line arguments
You can easily get a listing of the command-line arguments by typing in:
C:sqlcmd -?
as shown below:
C:Documents and Settings>sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 9.00.1399.06 NT INTEL X86
Copyright (c) Microsoft Corporation. All rights reserved.
usage: Sqlcmd [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w screen width]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-c cmdend] [-L[c] list servers[clean output]]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
[-u unicode output] [-r[0|1] msgs to stderr]
[-i inputfile] [-o outputfile] [-z new password]
[-f
| i:
[,o:
]] [-Z new password and exit]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-b On error batch abort]
[-v var = "value"...] [-A dedicated admin connection]
[-X[1] disable commands, startup script, environment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]
Next: A simple example of running an interactive session >>
More MS SQL Server Articles
More By Jayaram Krishnaswamy