06 December,2018 by Tom Collins
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)
How to Find SQL Server tcp port with Powershell
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |