Sqlism (9/12/2012)
Hope this link helps youhttp://sqlism.blogspot.com/2012/08/finding-port-number-for-particular-sql.html
Finding the Port Number for a particular SQL Server Instance
DECLARE @tcp_port nvarchar(5)
EXEC xp_regread
@rootkey = ‘HKEY_LOCAL_MACHINE’,
@key = ‘SOFTWARE\MICROSOFT\MSSQLSERVER\MSSQLSERVER\SUPERSOCKETNETLIB\TCP’,
@value_name = ‘TcpPort’,
@value = @tcp_port OUTPUT
select @tcp_port
This is not correct for a SQL Server 2005 onwards instance. Enumerate instance names from
HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server\Instance names\SQL
Then for each instance found get the 'TcpPort' value from (SQL Server 2008R2 example)
HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server\MSSQL10_50.instancename\MSSQLSERVER\SuperSocketNetLib\Tcp\IPAll
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉