How to specify a port number in SQL Server connection string?

Sql Server

Sql Server Problem Overview


I use the following connection string in SQL Server Management Studio. It failed to connect:

mycomputer.test.xxx.com:1234\myInstance1

But the following one is ok:

mycomputer.test.xxx.com\myInstance1

So how do I specify a port number in a connection string?

Sql Server Solutions


Solution 1 - Sql Server

Use a comma to specify a port number with SQL Server:

mycomputer.test.xxx.com,1234

It's not necessary to specify an instance name when specifying the port.

Lots more examples at http://www.connectionstrings.com/. It's saved me a few times.

Solution 2 - Sql Server

For JDBC the proper format is slightly different and as follows:

jdbc:microsoft:sqlserver://mycomputer.test.xxx.com:49843

Note the colon instead of the comma.

Solution 3 - Sql Server

The correct SQL connection string for SQL with specify port is use comma between ip address and port number like following pattern: xxx.xxx.xxx.xxx,yyyy

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsmwikipediaView Question on Stackoverflow
Solution 1 - Sql ServerMichael PetrottaView Answer on Stackoverflow
Solution 2 - Sql ServerShane KView Answer on Stackoverflow
Solution 3 - Sql ServerDavid ThangView Answer on Stackoverflow