BuildRowSetFromString()

Creates a rowset from a character string by splitting the string at the specified delimiter.

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ❌ No

Syntax 

1BuildRowSetFromString(sourceData, delimiter)

The BuildRowSetFromString() function has two parameters:

  • sourceData (string): Required. A string that contains the data to load into a rowset.
  • delimiter (string): Required. The character (such as a comma) that is used as a delimiter in the source data.

Usage 

To call the function, pass it the string of data that you want to convert to a rowset, and the character that is used as a delimiter in the source data.

Basic Usage 

This example creates a variable with a string of data, and another variable that contains the delimiter for that data. The example uses these variables to create a rowset from the string of data.

1%%[
2  Set @dataString = "123|456|789"
3  Set @dataDelimiter = "|"
4  BuildRowsetFromString(@dataString, @dataDelimiter)
5]%%

The example returns a rowset with three rows.

1123
2456
3789

Processing Attribute Names 

This example shows how to pass and process attribute names.

1%%[
2  Var @queryparams
3  Var @row
4  Var @name
5  Var @value
6  Set @queryparams = BuildRowsetFromString(QueryParameter('names'),'|')
7  For @i = 1 to Rowcount(@queryparams) do
8    Set @row = Row(@queryparams, @i)
9    Set @name = Field(@row,1)
10    Set @value = QueryParameter(@name)
11  ]%%
12  Passed <b>name:</b> %%=v(@name)=%% with <b>value:</b> %%=v(@value)=%%<br/>
13  %%[
14  next @i
15]%%

When passed the following input:

1names=career|firstname|lastname&career=marketer&firstname=Angela&lastname=Ruiz

The function returns:

1Passed name: career with value: marketer
2Passed name: firstname with value: Angela
3Passed name: lastname with value: Ruiz

Because this function returns the rowset in one column, and this column doesn’t have an assigned name, you refer to the column within a function using an ordinal number:

1Field(Row(BuildRowSetFromString('123|456', '|'), 1), 1)