Identify the port that sql server is running on

Identify the port that SQL Server is running on:

DECLARE @tcp_port nvarchar(5)

EXEC xp_regread
@rootkey    =    ‘HKEY_LOCAL_MACHINE’,
@key        =    ‘SOFTWAREMICROSOFTMSSQLSERVERMSSQLSERVERSUPERSOCKETNETLIBTCP’,
@value_name    =    ‘TcpPort’,
@value        =    @tcp_port OUTPUT

select @tcp_port

Leave a comment