STRING_SPLIT Function - SQL Server to PostgreSQL Migration

In SQL Server, the STRING_SPLIT is a table-valued function that splits a string into a set of rows based on the specified separator. In PostgreSQL, you can use UNNEST and STRING_TO_ARRAY functions.

SQL Server:

  -- Split string using comma (,) as separator
  SELECT * FROM STRING_SPLIT('a,b,c', ',');

PostgreSQL:

  -- Split string to array using comma (,) as separator and then convert to rows
  SELECT * FROM (SELECT UNNEST(STRING_TO_ARRAY('a,b,c', ',')) AS value);

Both queries return the following result:

value
a
b
c

For more information, see SQL Server to PostgreSQL Migration.