How to find SQL Server running port?

后端 未结 13 629
再見小時候
再見小時候 2020-11-28 20:10

Yes I read this How to find the port for MS SQL Server 2008?

no luck.

telnet 1433

returns connection failed, so I must s

相关标签:
13条回答
  • 2020-11-28 20:11

    If you can start the Sql Server Configuration Manager > SQL Server Network Configuration > Your instance > TCP/IP > Properties

    0 讨论(0)
  • 2020-11-28 20:18

    If you have run "netstat -a -b -n" (from an elevated command prompt) and you don't see "sqlservr.exe" at all then either your SQL Server service is not running or its TCP/IP network library is disabled.

    Run SQL Server Configuration Manager (Start | All Programs | Microsoft SQL Server 2008 | Configuration Tools).

    Navigate to SQL Server Services. In the right-hand pane look for SQL Server (). Is it stopped? If so, start it.

    Navigate to SQL Server Network Configuration (or SQL Server Network Configuration (32-bit) as appropriate) then Protocols for . In the right-hand pane look for "TCP/IP". Is it disabled? If so, enable it, then restart the SQL Server service.

    Note that he Instance ID will be MSSQLSERVER for the default instance.

    Please also note that you don't have to enable the TCP/IP network library to connect a client to the service. Clients can also connect through the Shared Memory network library (if the client is on the same machine) or the Named Pipes network library.

    0 讨论(0)
  • 2020-11-28 20:21

    Try this:

    USE master
    GO
    xp_readerrorlog 0, 1, N'Server is listening on' 
    GO
    

    http://www.mssqltips.com/sqlservertip/2495/identify-sql-server-tcp-ip-port-being-used/

    0 讨论(0)
  • 2020-11-28 20:21

    This is another script that I use:

    -- Find Database Port script by Jim Pierce  09/05/2018
    
    USE [master]
    GO
    
    DECLARE @DynamicportNo NVARCHAR(10);
    DECLARE @StaticportNo NVARCHAR(10);
    DECLARE @ConnectionportNo INT;
    
    -- Look at the port for the current connection
    SELECT @ConnectionportNo = [local_tcp_port]
     FROM sys.dm_exec_connections
        WHERE session_id = @@spid;
    
    -- Look for the port being used in the server's registry
    EXEC xp_instance_regread @rootkey = 'HKEY_LOCAL_MACHINE'
                            ,@key =
                             'Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IpAll'
                            ,@value_name = 'TcpDynamicPorts'
                            ,@value = @DynamicportNo OUTPUT
    
    EXEC xp_instance_regread @rootkey = 'HKEY_LOCAL_MACHINE'
                            ,@key =
                             'Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IpAll'
                            ,@value_name = 'TcpPort'
                            ,@value = @StaticportNo OUTPUT
    
    SELECT [PortsUsedByThisConnection] = @ConnectionportNo
          ,[ServerStaticPortNumber] = @StaticportNo
          ,[ServerDynamicPortNumber] = @DynamicportNo
    GO
    
    0 讨论(0)
  • 2020-11-28 20:24

    This is the one that works for me:

    SELECT DISTINCT 
        local_tcp_port 
    FROM sys.dm_exec_connections 
    WHERE local_tcp_port IS NOT NULL 
    
    0 讨论(0)
  • 2020-11-28 20:27

    Maybe it's not using TCP/IP

    Have a look at the SQL Server Configuration Manager to see what protocols it's using.

    0 讨论(0)
提交回复
热议问题