ARRAY_TO_STRING

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Converts an array to a string using a separator and an optional null indicator.

Syntax 

1ARRAY_TO_STRING(<array>, <separator>[, null_string])

Arguments 

Required 

  • <array>: The array to convert.
  • <separator>: The delimiter to insert between elements.

Optional 

  • null_string: The string to use for NULL elements.

Returns 

Returns a text value that contains all array elements joined by the separator. Without the optional null_string parameter, NULL elements are omitted from the output.

Examples 

Basic Conversion 

Convert an array to a semicolon-separated string.

1SELECT ARRAY_TO_STRING(array[1, 2, 3, NULL], ';') AS result;

Returns '1;2;3', joining all elements with semicolons. The NULL element was ignored because no NULL value was specified.

Handle NULL Elements 

Convert an array with NULL values using a custom null indicator.

1SELECT ARRAY_TO_STRING(array[3, 2, 1, null], '-', 'N/A') AS result;

Returns '3-2-1-N/A', replacing the NULL element with the specified indicator.

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!