how to obtain SQL server port number code example
Example 1: sql server check port number
USE master
GO
xp_readerrorlog 0, 1, N'Server is listening on'
GO
#LogDate ProcessInfo Text
#... Server Server is listening on [ ::1 <ipv6> 1434].
#2.. Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
Example 2: sql server port number
By default SQL Server listens on TCP port number 1433, but for named instances the TCP port is dynamically configured. There are several options available to get the listening port for a SQL Server named instance.