How to find the port for MS SQL Server 2008?

后端 未结 13 1756
广开言路
广开言路 2020-11-29 02:24

I am running MS SQL Server 2008 on my local machine. I know that the default port is 1433 but some how it is not listening at this port. The SQL is an Express edition.

13条回答
  •  攒了一身酷
    2020-11-29 03:05

    Here are 5 methodes i found:

    • Method 1: SQL Server Configuration Manager
    • Method 2: Windows Event Viewer
    • Method 3: SQL Server Error Logs
    • Method 4: sys.dm_exec_connections DMV
    • Method 5: Reading registry using xp_instance_regread

    Method 4: sys.dm_exec_connections DMV
    I think this is almost the easiest way...
    DMVs return server state that can be used to monitor SQL Server Instance. We can use sys.dm_exec_connections DMV to identify the port number SQL Server Instance is listening on using below T-SQL code:

    SELECT local_tcp_port
    FROM   sys.dm_exec_connections
    WHERE  session_id = @@SPID
    GO
    
    Result Set:
    local_tcp_port
    61499
    
    (1 row(s) affected)
    

    Method 1: SQL Server Configuration Manager

    Step 1. Click Start > All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager

    Step 2. Go to SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for

    Step 3. Right Click on TCP/IP and select Properties

    enter image description here

    Step 4. In TCP/IP Properties dialog box, go to IP Addresses tab and scroll down to IPAll group.

    enter image description here

    If SQL Server if configured to run on a static port it will be available in TCP Port textbox, and if it is configured on dynamic port then current port will be available in TCP Dynamic Ports textbox. Here my instance is listening on port number 61499.

    The other methods you can find here: http://sqlandme.com/2013/05/01/sql-server-finding-tcp-port-number-sql-instance-is-listening-on/

提交回复
热议问题