Find the port no Get Port SQL Server 2000

,

This Query is used to Find the port number or Get Port mumber SQL Server 2000 using T-SQL

 

Connect to the SQL Server which server you want find the port then open te query Analyser

use master
go
CREATE TABLE #GetPort
(token varchar(100),
value varchar(20))
go
DECLARE @inst varchar(200)
DECLARE @inst1 varchar(100)
IF(charindex('\',@@servername) > 0) 
BEGIN 
  SELECT @inst = substring(@@servername,charindex('\',@@servername),50) 
  SELECT @inst = 'SOFTWARE\Microsoft\Microsoft SQL 
Server'+@inst+'\MSSQLServer\SuperSocketNetLib\Tcp' 
  SELECT @inst1 = 'TcpDynamicPorts'
END
 ELSE
BEGIN SELECT @inst = 'SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib\Tcp' 
SELECT @inst1 = 'DefaultPort'
END

INSERT #GetPort 
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',@inst,@inst1 

SELECT value FROM #GetPort
DROP TABLE #GetPort

Rate

4 (1)

Share

Share

Rate

4 (1)