How to get SQL port number using xp_readererrorlog

06 December,2018 by Jack Vamvas

Question: Without going into the SQL Server Configuration manager via the GUI is there a command oriented method to extract the port number SQL Server is listening on?

 

Answer: There are a few different methods to extract the port number without going into the Configuration interface.

Method 1 - use xp_readererrorlog

When SQL Server starts up it goes through a number of checks and records these in the SQL Server Error log files. one of the checks relates to ports SQL Server is listening on.

This is an example to extract the port number . The first example is for 'any'  , the second example returns all other details

 

USE master

GO

xp_readerrorlog 0, 1, N'Server is listening on',N'any', NULL, NULL, N'asc'

GO

--results

LogDate ProcessInfo Text
2018-11-16 23:19:41.730 spid21s Server is listening on [ 'any' <ipv6> 513245].

USE master

GO

xp_readerrorlog 0, 1, N'Server is listening on',N'', NULL, NULL, N'asc'

GO

--results

2018-11-16 23:19:41.730 spid23s Server is listening on [ 'any' <ipv6> 513245 ].
2018-11-16 23:19:41.740 spid23s Server is listening on [ 'any' <ipv4> 60333].
2018-11-16 23:19:41.740 Server Server is listening on [ ::1 <ipv6> 60332].
2018-11-16 23:19:41.740 Server Server is listening on [ 127.0.0.1 <ipv4> 60332].

 

Other methods to discover port numbers

How to find the local tcp port used on SQL Server (SQL Server DBA)

SQL Server – Find SQL Server tcp port with Powershell (SQL Server ...

 


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to get SQL port number using xp_readererrorlog


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer