SERVERPROPERTY Function - SQL Server to PostgreSQL Migration

In SQL Server, the SERVERPROPERTY function returns the current value for the specified server property.

In PostgreSQL, you have to use a specific function or expression for every individual property. Also, as most properties are SQL Server specific, they maybe irrelevant in PostgreSQL.

ServerName Property

The ServerName property returns the Windows server and instance name:

SQL Server:

  -- Get the SQL Server host and instance name
  SELECT SERVERPROPERTY('ServerName');
  /* DMT14\SQLEXPRESS */

There is no a built-in function to retrieve the host name of the running PostgreSQL server, so you can to use the IP address to identify your PostgreSQL instance:

PostgreSQL:

  -- Get the server IP address
  SELECT INET_SERVER_ADDR();
  /* ::1 */

Note that value ::1 was returned for the PostgreSQL instance running on localhost 127.0.0.1.

For more information, see SQL Server to PostgreSQL Migration.