Technical Article

Retrieve SQL Instance Connect Info

,

This script provides a quick and easy way to get some useful connection information from your SQL Server instances.  It is very helpful if you have a SQL cluster running multiple instances and want to quickly find out what node the instance is running on or the IP address or port for each of your instances. 

--This returns Server Name, Cluster Node, Default Drive Letter, IP address and Port
SELECTSERVERPROPERTY('ServerName') as 'Server\Instance', 
SERVERPROPERTY('ComputerNamePhysicalNetBIOS') as 'Node', 
(select left(af.filename,3)from sys.sysaltfiles af where af.name like '%MSDB%' and af.fileid = 1) as 'Drive', 
ec.local_net_address as 'IP Addr', 
ec.local_tcp_port as 'SQL Port'
from sys.dm_exec_connections ec 
where ec.session_id = @@SPID

Rate

5 (2)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (2)

You rated this post out of 5. Change rating