In most of the forums I’ve seen that users are not able to find on which port does their sql server is listening. Hence I decided to write a script to check TCPIP port on which sql server is listening. Checkout the below script.
Script:
DECLARE @key VARCHAR(50), @RegistryPath VARCHAR(200) IF (SERVERPROPERTY('INSTANCENAME')) IS NULL BEGIN SET @RegistryPath='Software\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib\Tcp' END ELSE BEGIN SET @RegistryPath='Software\Microsoft\Microsoft SQL Server\'+CONVERT(VARCHAR(25),SERVERPROPERTY('INSTANCENAME')) + '\MSSQLServer\SuperSocketNetLib\Tcp' END EXEC master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', @RegistryPath, 'tcpPort'
Output
Value | Data |
tcpPort | 1433 |
Leave a Reply