找回密码
 注册

QQ登录

只需一步,快速开始

查看: 606|回复: 1

Finding the Port Number for a particular SQL Server Instance

[复制链接]
发表于 2011-6-5 00:46:30 | 显示全部楼层 |阅读模式
One of the developers recently asked me this question: “I have a SQL Server instance running – how can I tell what port it is running on?”.  There are a couple of ways of finding this information.
1) Using the GUI: In SQL Server 2000, you can use the Server Network Utility and in SQL Server 2005, you can use the SQL Server Configuration Manager.  Look under SQL Server 2005 Network Configuration and look at the TCP port for the TCP/IP protocol.
2)  Check the error log.  You will see an entry like: “Server is listening on [ 'any' <ipv4> 1433].”  The last 4 numbers denote the TCP/IP port number that is being used by that particular instance of SQL Server.
3)  Registry entry: HKLM\Software\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib\TCP
and you will see TCPPort as one of the entries and it’s value represents the port number for that instance.  In case you are using a named instance, then the registry entry will be: HKLM\Software\Microsoft\Microsoft SQL Server\<name of the instance>\MSSQLServer\SuperSocketNetLib\TCP
4) Using the extended stored procedure xp_regread, you can find out the value of the TcpPort by using SQL.  Example:
DECLARE @tcp_port nvarchar(5)
EXEC xp_regread
@rootkey    =    ‘HKEY_LOCAL_MACHINE’,
@key        =    ‘SOFTWARE\MICROSOFT\MSSQLSERVER\MSSQLSERVER\SUPERSOCKETNETLIB\TCP’,
@value_name    =    ‘TcpPort’,
@value        =    @tcp_port OUTPUT
select @tcp_port
5) You can also chose to trace the client to server communication by using Microsoft Network Monitor or a network sniffer utility.  You can also use the TCP/IP netstat utility.  Example: Using “netstat -an” on the database server, I get:
  Proto  Local Address                 Foreign Address           State
TCP    192.168.20.196:1433    192.168.20.70:3655     ESTABLISHED
TCP    192.168.20.196:1433    192.168.20.70:3664     ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.15:5277     ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.15:5286     ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.15:5795     ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.123:1162    ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.123:1177    ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.123:1186    ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.126:3529    ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.126:3540    ESTABLISHED
TCP    192.168.20.196:1433    192.168.70.126:4088    ESTABLISHED
In this case, the IP Address “192.168.20.196″ is the IP address of the SQL Server box where the instance is running and the other IP addresses are the IP addresses of the client machines from where the connections are being established.


http://decipherinfosys.wordpress.com/2008/01/02/finding-the-port-number-for-a-particular-sql-server-instance/

发表于 2011-6-7 22:39:22 | 显示全部楼层
楼主的这个帖子不错哈

千年遇好帖,遇到必须顶

顶一下看看


Millasha,Millasha,Millasha,Millasha官网地址,Millasha
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-10 20:20 , Processed in 0.013978 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表