Skip to content
Advertisement

Snowflake how to split a field having values separated with commas and add them separately to the target table each value in a single row?

I have a field that might hold values as follows:

field_val = ‘Val1, Val2’;

So using merge into command, I need to split these values and add them separately each as a single row.

In that case, I don’t want them added row to be: 23, 'Val1, Val2'

What I want is to add the separately as single rows:

23, 'Val1'

24, 'Val2'

Advertisement

Answer

You can use LATERAL SPLIT_TO_TABLE to split the array to a table, but I don’t think that you can add them with different IDs.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement