This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one important T-SQL script to find out PORT information of the SQL Server Instance.
When SQL Database Administrators are dealing with multiple SQL instances, this kind of script helps a lot to DBA.
The Even Database Administrator can use this script for reporting purposes.
Below T-SQL script to find PORT information of the current instance:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SET NOCOUNT ON DECLARE @Port VARCHAR(30) ,@Key VARCHAR(150) IF CHARINDEX('\',@@SERVERNAME,0) <>0 BEGIN SET @Key = 'SOFTWARE\MICROSOFT\Microsoft SQL Server\' +@@SERVICENAME+'\MSSQLServer\Supersocketnetlib\TCP' END ELSE BEGIN SET @Key = 'SOFTWARE\MICROSOFT\MSSQLServer\MSSQLServer \Supersocketnetlib\TCP' END EXEC master.sys.xp_regread @Rootkey='HKEY_LOCAL_MACHINE' ,@Key=@Key,@value_name='Tcpport' ,@value=@Port OUTPUT SELECT 'SQL Server Name: '+@@SERVERNAME + ' Port # '+CONVERT(VARCHAR(20),@Port) |
Leave a Reply