SAP HANA: find SQL port numbers with M_SERVICES
Query SYS.M_SERVICES to list the SQL ports of a SAP HANA instance.
To find the SQL ports of a SAP HANA instance, query the SYS.M_SERVICES system view from any SQL client (hdbsql, SAP HANA Studio, etc.).
SELECT DISTINCT(sql_port) FROM SYS.M_SERVICES WHERE SQL_PORT > 0
Explanation
SYS.M_SERVICESlists the database services (nameserver, indexserver, etc.) with their status and ports.- The
SQL_PORT > 0filter excludes services that do not expose a SQL port (the value is 0). DISTINCTremoves duplicates.