Friday, June 05, 2009

[SQL] Force the protocol (TCP, Named Pipes, etc.) in your connection string - Jon Galloway

Learn something new every day.  Until now, I was using the sql client alias configuration tool to set this one up.

No more dependencies on server admins!

Barry Dorrans recently mentioned that you can force the database connection protocol by specifying np: or tcp: before the server name in your connection string. I've jumped through some hoops before using localhost to target tcp and (local) to target named pipes, but it looks like there's a much better way to do this (since MDAC 2.6).

There's more info in MS KB Article 313295:

TCP/IP:

server=tcp:hostname

You can optionally specify a specific port number. By default, the port is 1433.

server=tcp:hostname, portNumber


Named Pipes:



server=np:hostname

You can optionally specify a specific named pipe.



server=np:\\hostname\pipe\pipeName




[SQL] Force the protocol (TCP, Named Pipes, etc.) in your connection string - Jon Galloway

No comments: