﻿<?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 Vijendran R  / Find SQL Server TCP/IP Port Number / 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, 25 May 2013 14:47:18 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Find SQL Server TCP/IP Port Number</title><link>http://www.sqlservercentral.com/Forums/Topic752494-1597-1.aspx</link><description>Hello everyone,Here is the code that will also scan SQL 2008 servers--SQL 2000/2005/2008 Versionset nocount ongoDECLARE @SqlPort Nvarchar(10)DECLARE @instance_name Nvarchar(30)DECLARE @reg_key Nvarchar(500)Declare @value_name Nvarchar(20)if left(CAST(SERVERPROPERTY('ProductVersion')AS sysname),2) = '10'BEGINselect @instance_name = CAST(SERVERPROPERTY('instancename')AS sysname)if @instance_name is NULLBEGINset @reg_key = 'SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\AdminConnection\Tcp'--END--ELSE BEGIN--set @reg_key = 'SOFTWARE\Microsoft\Microsoft SQL Server\' + @instance_name + '\MSSQLServer\SuperSocketNetLib\Tcp'ENDEXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key=@reg_key, @value_name='TcpDynamicPorts',@value=@SqlPort outputselect CAST(SERVERPROPERTY('ServerName')AS sysname) as ServerName, @SqlPort as PortEND--------------------------------------------------------------------if left(CAST(SERVERPROPERTY('ProductVersion')AS sysname),1) = '9'BEGINselect @instance_name = CAST(SERVERPROPERTY('instancename')AS sysname)if @instance_name is NULLBEGINset @reg_key = 'SOFTWARE\Microsoft\MSSQLServer\MSSQlServer\SuperSocketNetLib\Tcp'ENDELSE BEGINset @reg_key = 'SOFTWARE\Microsoft\Microsoft SQL Server\' + @instance_name + '\MSSQLServer\SuperSocketNetLib\Tcp'ENDEXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key=@reg_key, @value_name='TcpPort',@value=@SqlPort outputselect CAST(SERVERPROPERTY('ServerName')AS sysname) as ServerName, @SqlPort as PortENDif left(CAST(SERVERPROPERTY('ProductVersion')AS sysname),1) = '8'BEGINCreate 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_2000select CAST(SERVERPROPERTY('ServerName')AS sysname) as ServerName, @SqlPort as Portdrop table #Port_2000END</description><pubDate>Thu, 13 May 2010 09:03:23 GMT</pubDate><dc:creator>Rudy Panigas</dc:creator></item><item><title>RE: Find SQL Server TCP/IP Port Number</title><link>http://www.sqlservercentral.com/Forums/Topic752494-1597-1.aspx</link><description>Nice code. Any idea where to fine the port number for SQL 2008?</description><pubDate>Thu, 13 May 2010 08:09:05 GMT</pubDate><dc:creator>Rudy Panigas</dc:creator></item><item><title>RE: Find SQL Server TCP/IP Port Number</title><link>http://www.sqlservercentral.com/Forums/Topic752494-1597-1.aspx</link><description>[quote][b]SQLGerman (7/20/2009)[/b][hr]I think we should start using the SQL CLR to accomplish all this going forward.[/quote]Not every one is capable of coding CLR modules and that's a lot of unnecessary overhead for simple info gathering, IMHO.</description><pubDate>Thu, 13 May 2010 07:08:17 GMT</pubDate><dc:creator>BlackHawk-17</dc:creator></item><item><title>RE: Find SQL Server TCP/IP Port Number</title><link>http://www.sqlservercentral.com/Forums/Topic752494-1597-1.aspx</link><description>I think we should start using the SQL CLR to accomplish all this going forward. But, a good code though.</description><pubDate>Mon, 20 Jul 2009 05:11:37 GMT</pubDate><dc:creator>SQLGerman</dc:creator></item><item><title>Find SQL Server TCP/IP Port Number</title><link>http://www.sqlservercentral.com/Forums/Topic752494-1597-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/Miscellaneous/67422/"&gt;Find SQL Server TCP/IP Port Number&lt;/A&gt;[/B]</description><pubDate>Tue, 14 Jul 2009 01:05:42 GMT</pubDate><dc:creator>vijendran</dc:creator></item></channel></rss>