0% found this document useful (0 votes)
351 views3 pages

Connect Using SQLCMD

The document discusses different methods for connecting to a SQL Server database using the sqlcmd utility. It explains that sqlcmd will use TCP/IP, named pipes, or shared memory depending on what is specified in the connection string or alias. It then provides examples of connecting statements using different protocols, specifying an instance name, IP address, or port number. The document emphasizes that specifying "tcp:" will force sqlcmd to use TCP/IP even when connecting to a named instance.

Uploaded by

infombm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
351 views3 pages

Connect Using SQLCMD

The document discusses different methods for connecting to a SQL Server database using the sqlcmd utility. It explains that sqlcmd will use TCP/IP, named pipes, or shared memory depending on what is specified in the connection string or alias. It then provides examples of connecting statements using different protocols, specifying an instance name, IP address, or port number. The document emphasizes that specifying "tcp:" will force sqlcmd to use TCP/IP even when connecting to a named instance.

Uploaded by

infombm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Connect to the Database Engine With sqlcmd

SQL Server 2016

SQL Server supports client communication with the TCP/IP network protocol (the default), and
the named pipes protocol. The shared memory protocol is also available if the client is connecting
to an instance of the Database Engine on the same computer. There are three common methods of
selecting the protocol. The protocol used by the sqlcmd utility is determined in the following
order:

 sqlcmd uses the protocol specified as part of the connection string as described below.
 If no protocol is specified as part the connection string, sqlcmd will use the protocol defined
as part of the alias that it is connecting to. To configure sqlcmd to use a specific network
protocol by creating an alias, see Create or Delete a Server Alias for Use by a Client (SQL
Server Configuration Manager).
 If the protocol is not specified in some other way, sqlcmd will use the network protocol
determined by the protocol order in SQL Server Configuration Manager.

The following examples show various ways of connecting to the default instance of Database
Engine on port 1433, and named instances of Database Engine presumed to be listening on port
1691. Some of these examples use the IP address of the loopback adapter (127.0.0.1). Test using
the IP address of your computer network interface card.

Connect to the Database Engine by specifying the instance name:

sqlcmd -S ComputerA
sqlcmd -S ComputerA\instanceB

Connect to the Database Engine by specifying the IP address:

sqlcmd -S 127.0.0.1
sqlcmd -S 127.0.0.1\instanceB

Connect to the Database Engine by specifying the TCP\IP port number:

sqlcmd -S ComputerA,1433
sqlcmd -S ComputerA,1691
sqlcmd -S 127.0.0.1,1433
sqlcmd -S 127.0.0.1,1691
To connect using TCP/IP

 Connect using the following general syntax:

sqlcmd -S tcp:<computer name>,<port number>

 Connect to the default instance:

sqlcmd -S tcp:ComputerA,1433
sqlcmd -S tcp:127.0.0.1,1433

 Connect to a named instance:

sqlcmd -S tcp:ComputerA,1691
sqlcmd -S tcp:127.0.0.1,1691

To connect using named pipes

 Connect using one of the following general syntax:

sqlcmd -S np:\\<computer name>\<pipe name>


 Connect to the default instance:

sqlcmd -S np:\\ComputerA\pipe\sql\query
sqlcmd -S np:\\127.0.0.1\pipe\sql\query
 Connect to a named instance instance:

sqlcmd -S np:\\ComputerA\pipe\MSSQL$<instancename>\sql\query
sqlcmd -S np:\\127.0.0.1\pipe\MSSQL$<instancename>\sql\query

To connect using shared memory (a local procedure call) from a client on the
server

 Connect using one of the following general syntax:

sqlcmd -S lpc:<computer name>


 Connect to the default instance:

sqlcmd -S lpc:ComputerA
 Connect to a named instance: sqlcmd -S lpc:ComputerA\<instancename>
Remember to read the full documentation...

If you need to connect to named instance, from SQLCMD.exe and want to force it to use the TCP
protocol you should just use the following command:

sqlcmd -S tcp:SERVER\INSTANCE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy