开发者

Simple way to tell which ports is SQL Server is running on using SQLCMD?

I have开发者_开发知识库 3 Sql server instances on my machine, but I don't recall which port each is running on. I can run the config manager to find this, but is there an easier way to do it from SQLCMD?


This query will return the TCP port used.

SELECT
    e.name as ProtocolName
    ,ec.local_tcp_port as Port
    ,ec.local_net_address as IP
FROM
    sys.endpoints e
LEFT JOIN
    sys.dm_exec_connections ec
ON
    ec.endpoint_id = e.endpoint_id
where
      e.name = 'TSQL Default TCP'
GROUP BY
    e.name
    ,ec.local_tcp_port
    ,ec.local_net_address
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜