How To Find Sql Server 2012 Tcp Port Number

An easy way to find TCP IP Port number in SQL Server 2012.

IF @@version LIKE '%Microsoft SQL Server 2012%'
    BEGIN
    DECLARE @tcp_port nvarchar(10)
    EXEC XP_REGREAD
    @rootkey    =    'HKEY_LOCAL_MACHINE',
    @key        =    'SOFTWARE\MICROSOFT\Microsoft SQL Server\MSSQL11.UAT2012\MSSQLServer\SUPERSOCKETNETLIB\TCP\IPAll',
    @value_name    = 'TcpPort',
    @value        =    @tcp_port OUTPUT
    SELECT @tcp_port AS TCPIP_Port
END
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License