Sqlcmd is a command-line tool for manipulating SQL Server, and Query Analyzer is its graphical tool
Query Analyzer (SQL2005 called Managerment Studio) , connected to the remote SQLSERVER2005, if it is 1433 port, using the default instance name, Telnet time directly in the server name input box to enter the destination IP address can be easily done.
If the SQL2005 on a server is not using 1433 ports, but 1434 ports, the connection will not be directly input IP,
This time we need to enter:
Ip\ < instance name >,< port number;
Less one is not connected (I test under SQLSERVER2005, I do not know the future version will not be so troublesome), such as I want to connect the IP address is: 192.168.1.55, the instance name is SQL2005, The port number is 1434 SQLSERVER2005 server, then I need to enter in the Server name field: ,
192.168.1.55\sql2005,1434
above is to use the graphics tool to connect SQLSERVER2005, Below we say the command line under the connection SQLSERVER2005 server
SQLSERVER2005 command line tool under the name is SQLCMD (the command line tool for sqlserver2000 is osql),
Its connection format is:
SQLCMD -u user name-p password-S IP address <
If the port number is omitted, the default connection is 1433 port
It has a slightly different connection method and Query Analyzer, assuming that the password for the SQL2005 server SA on 192.168.1.55 is SA, The port is 1434
We can connect like this
sqlcmd-u sa-p sa-s 192.168.1.55,1434
If you connect port 1433, you can omit the port: sqlcmd-u sa-p sa-s 192.168.1.55 (also note that-u,-p,-s must be uppercase Oh, there is a comma between the IP address and the port number)
If you want to know other ways to use it, you can enter
SQLCMD/?
in the command line. The more useful parameters that I personally think are the-I (Execute SQL file)-d (select database)
Use Query Analyzer and sqlcmd to log on to the remote SQL2005 1434 port separately