SQL Server port number

Configurare noua (How To)

Situatie

Pentru cazurile in care avem nevoie rapid de aceasta informatie, am creat o procedura ce citeste registri si returneaza numarul portului pe care serverul SQL este configurat sa ruleze.

Solutie

create procedure BD_SqlServerPortNumber_prc

as

DECLARE @test varchar(15),
@value_name varchar(15),
@RegistryPath varchar(200)

IF (charindex(‘\’,@@SERVERNAME)<>0)
BEGIN
SET @RegistryPath = ‘SOFTWARE\Microsoft\Microsoft SQL Server\’ + RIGHT(@@SERVERNAME,LEN(@@SERVERNAME)-CHARINDEX(‘\’,@@SERVERNAME)) +
‘\MSSQLServer\SuperSocketNetLib\Tcp’
END
ELSE
BEGIN
SET @RegistryPath = ‘SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib\Tcp’
END

EXEC master..xp_regread @rootkey=’HKEY_LOCAL_MACHINE’ ,
@key=@RegistryPath,@value_name=’TcpPort’,
@value=@test OUTPUT

Print ‘The Port Number is ‘+ @test

Tip solutie

Permanent

Voteaza

(3 din 13 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?