﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Dan  Hess  / Find which port SQL Server is using to establish connections / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 05:07:00 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>Thank you.  Good discussion started, good job.</description><pubDate>Thu, 08 Sep 2011 10:03:05 GMT</pubDate><dc:creator>GAF</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>on 2K8: xp_ReadErrorLog 0, 1, 'listening'-- Parameters defined:-- Parameter 1 (int), is the number of the log file you want to read, default is "0" for current log. -- Parameter 2 (int), value of 1 reads SQL error logs, value of 2 reads SQL Server Agent logs, with a default value of 1.-- Parameter 3 varchar (255), is a search string for the log entry, with a default value of NULL.-- Parameter 4 varchar (255), is another search string for the log entry, with a default value of NULL</description><pubDate>Thu, 08 Sep 2011 09:40:10 GMT</pubDate><dc:creator>noelc</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>Figured I would throw one more method, albeit quite a bit more manual.  You can also check the error log in found in the Log folder where your SQL Server is installed  (for example, C:\Program Files\Microsoft SQL Server\MSSQL.1\Log).  The latest log file will be named ERRORLOG (w/out the numbered extension).  Using a standard text editor, like Notepad, you can do a quick search for the text 'listening'.</description><pubDate>Thu, 08 Sep 2011 08:21:44 GMT</pubDate><dc:creator>tskelley</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>Nice simple article. We could also get this information from SQL Server error log.</description><pubDate>Thu, 08 Sep 2011 05:12:00 GMT</pubDate><dc:creator>mohammed moinudheen</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>You can also use the following from the command line : [code="plain"]netstat -n -b[/code]You can then check the returned values for the executable you're interested in to see the port (or ports) being listened on. </description><pubDate>Thu, 08 Sep 2011 03:30:28 GMT</pubDate><dc:creator>Steve Smith-149662</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>How about using this for a TSQL based solution?:SELECT DISTINCT(local_tcp_port) FROM sys.dm_exec_connectionsWHERE net_transport='TCP'</description><pubDate>Thu, 08 Sep 2011 02:22:06 GMT</pubDate><dc:creator>Lawrence Moore</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>Thanks for the tips; For info:I found out though that the only way that worked for me was to check the event details - although for that I had to restart the server to generate new events.With regards to the second option, I have no values displayed in that field, or any other fields labeled "Port" in that IP-Addresses tab.The third option had to be tinkered with a wee bit - @@SERVICENAME returns MSSS2008R2but the key is actually found under MSSQL10_50.MSSQLSERVER2008R2and then, just like for option 2, that tcp key value is empty anyway:Value	DatatcpPort	NULLthanks again for the tips,B</description><pubDate>Thu, 08 Sep 2011 02:20:23 GMT</pubDate><dc:creator>bertrand.leroy</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>If you are connected (using the instance name) you can also find it by query (SQl2000 and up):set nocount ongoDECLARE @SqlPort Nvarchar(10), @instance_name Nvarchar(30), @reg_key Nvarchar(500), @value_name Nvarchar(20)if left(CAST(SERVERPROPERTY('ProductVersion')AS sysname),2) = '10'BEGIN	select @instance_name = CAST(SERVERPROPERTY('instancename')AS sysname)	if @instance_name is NULL	BEGIN		set @reg_key = 'SOFTWARE\Microsoft\MSSQLServer\MSSQlServer\SuperSocketNetLib\Tcp'	END	ELSE BEGIN		set @reg_key = 'SOFTWARE\Microsoft\Microsoft SQL Server\' + @instance_name + '\MSSQLServer\SuperSocketNetLib\Tcp'	END	EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', 	@key=@reg_key, @value_name='TcpPort',	@value=@SqlPort output	select CAST(SERVERPROPERTY('ServerName')AS sysname) as ServerName, @SqlPort as PortENDif left(CAST(SERVERPROPERTY('ProductVersion')AS sysname),1) = '9'BEGIN	select @instance_name = CAST(SERVERPROPERTY('instancename')AS sysname)	if @instance_name is NULL	BEGIN		set @reg_key = 'SOFTWARE\Microsoft\MSSQLServer\MSSQlServer\SuperSocketNetLib\Tcp'	END	ELSE BEGIN		set @reg_key = 'SOFTWARE\Microsoft\Microsoft SQL Server\' + @instance_name + '\MSSQLServer\SuperSocketNetLib\Tcp'	END	EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', 	@key=@reg_key, @value_name='TcpPort',	@value=@SqlPort output	select CAST(SERVERPROPERTY('ServerName')AS sysname) as ServerName, @SqlPort as PortENDif left(CAST(SERVERPROPERTY('ProductVersion')AS sysname),1) = '8'BEGIN	Create table #Port_2000 (value nvarchar(20),Data nVarchar(10))	insert into #Port_2000 exec master..xp_instance_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\Supersocketnetlib\tcp', 'tcpPort'	select @SqlPort = Data from #Port_2000	select CAST(SERVERPROPERTY('ServerName')AS sysname) as ServerName, @SqlPort as Port	drop table #Port_2000END</description><pubDate>Thu, 08 Sep 2011 02:09:18 GMT</pubDate><dc:creator>d.majoor</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>I really liked this article. It's short and simple, and I learned something:-)</description><pubDate>Thu, 08 Sep 2011 01:27:39 GMT</pubDate><dc:creator>Håvard</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>[quote][b]Avinash Barnwal (9/7/2011)[/b][hr]The third way doesn't seem to be option to find out which of the port SQL Server is listening, since if you are already connected to the SQL server, then [b]you already know the Port[/b].[/quote]Not completely true. You can connect using a named instance and never know the port you're attaching to.The SQL Browser service listens on port UDP 1434 and returns the port of the named instances in a datagram. The client application parses the datagram and connects to the port returned by the SQL Browser.</description><pubDate>Thu, 08 Sep 2011 01:15:54 GMT</pubDate><dc:creator>spaghettidba</dc:creator></item><item><title>RE: Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>The third way doesn't seem to be option to find out which of the port SQL Server is listening, since if you are already connected to the SQL server, then you already know the Port.</description><pubDate>Wed, 07 Sep 2011 23:21:40 GMT</pubDate><dc:creator>Avinash Barnwal</dc:creator></item><item><title>Find which port SQL Server is using to establish connections</title><link>http://www.sqlservercentral.com/Forums/Topic1171523-2918-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/networking/73238/"&gt;Find which port SQL Server is using to establish connections&lt;/A&gt;[/B]</description><pubDate>Wed, 07 Sep 2011 23:20:11 GMT</pubDate><dc:creator>SQLDCH</dc:creator></item></channel></rss>