Question

I've noticed that if I don't supply a port when I build a connection string I can still connect to SQL Server via a named instance that looks like [SERVER][INSTANCE_NAME].

Is sqlclient automatically gathering the port number for me? Do I have to concern myself with port number even if the instance is the default instance?

I'm sorry if this question seems novice. Google just hasn't turned anything up for me.

Thank you!

Was it helpful?

Solution

Well usually the default port that SQL Server listens on is 1433 so you dont need to specify the port number in the connection string.

There is a nice article that gives some more info on the subject:

http://benchmarkitconsulting.com/colin-stasiuk/2009/02/02/what-tcp-port-is-sql-server-running-under/

OTHER TIPS

One thing to keep in mind though is that if you have multiple instances of SQL Server installed on the same computer, then each instance will use a different, random port number (although, a specific port number can be specified using the SQL Server Configuration Manager, right-click on the service & select Properties).

If you're connecting via the instance name though, and the SQL Server Browser service is running, it will redirect all requests to the appropriate ports automatically.

Another thing to keep in mind, is that the Express Edition (i.e. the free version) of SQL Server doesn't enable the TCP/IP protocol by default. I know this is the behaviour with older versions of SQL Server, but this may have changed in newer versions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top