Sql Server connection String including Port (1 Viewer)

Mr. B

"Doctor Access"
Local time
Today, 09:58
Joined
May 20, 2009
Messages
1,932
Does anyone have an example of an sql server connection string where the port is being specified?

I have seen threads that kinda indicate that the SQL Severe Native Client driver must be used when needing to specify the port but I have not been able to get a handle on the requirements.

Any assistance is appreciated.
 

Rx_

Nothing In Moderation
Local time
Today, 08:58
Joined
Oct 22, 2009
Messages
2,803
It has been too long since I used a Named Pipe. About two years ago, all of our SQL Servers had alternative ports for security. At least that is what they said it was for LOL.

I do think ODBC can be used to specify ports. I have just been a fan of SQL Server Native Client. It is actually based on ODBC. My guess is that anywhere there is a Server parameter, the port can be added as shown below. The default port is included in the ODBC configure dialogue. There were times on a Novel network that even though the port was 1422 (the standard) my ODBC would not connect unless the Custom port was chosen, and 1422 was specifically asked for. That was probably more of an old Novel issue.

If you are using TCP/IP (using the network library parameter) and database mirroring, including port number in the address (formed as servername,portnumber) for both the main server and the failover partner can solve some reported issues.

The network address of the server running an instance of SQL Server. Address is usually the network name of the server, but can be other names such as a pipe, an IP address, or a TCP/IP port and socket address.
If you specify an IP address, make sure that the TCP/IP or named pipes protocols are enabled in SQL Server Configuration Manager.
The value of Address takes precedence over the value passed to Server in ODBC connection strings when using SQL Server Native Client. Also note that Address=; will connect to the server specified in the Server keyword, whereas Address= ;, Address=.;, Address=localhost;, and Address=(local); all cause a connection to the local server.
The complete syntax for the Address keyword is as follows:
[protocol:]Address[,port |\pipe\pipename]
protocol can be tcp (TCP/IP), lpc (shared memory), or np (named pipes). For more information about protocols, see Configure Client Protocols.
If neither protocol nor the Network keyword is specified, SQL Server Native Client will use the protocol order specified in SQL Server Configuration Manager.
port is the port to connect to, on the specified server. By default, SQL Server uses port 1433.

The name of a SQL Server instance. The value must be either the name of a server on the network, an IP address, or the name of a SQL Server Configuration Manager alias.
The Address keyword overrides the Server keyword.
You can connect to the default instance on the local server by specifying one of the following:
Server=;
Server=.;
Server=(local);
Server=(localhost);
Server=(localdb)\ instancename ;
For more information about LocalDB support, see SQL Server Native Client Support for LocalDB.
To specify a named instance of SQL Server, append \InstanceName.
When no server is specified, a connection is made to the default instance on the local computer.
If you specify an IP address, make sure that the TCP/IP or named pipes protocols are enabled in SQL Server Configuration Manager.
The complete syntax for the Server keyword is as follows:
Server= [protocol:]Server[,port]

Hope that helps.
 

Mr. B

"Doctor Access"
Local time
Today, 09:58
Joined
May 20, 2009
Messages
1,932
As it turns out, it is possible to include the Port in with the server.
All you need to do is to separate the server from the port with a comma. Works great.
 

Users who are viewing this thread

Top Bottom