SQL Eval Function String_SplitRemoveEmptyEntries
String_SplitRemoveEmptyEntries returns a string array that contains the substrings in the source string that are delimited by elements of a specified delimStr string. The return value does not include array elements that contain an empty string.
String_SplitRemoveEmptyEntries ( @source NVARCHAR (MAX), @delimStr NVARCHAR (MAX) ) RETURNS TABLE ([Match] NVARCHAR (MAX) NULL)
Parameters
- source: The source string.
- delimStr: A string that is converted to character array that delimits the substrings in the
sourcestring, an empty array that contains no delimiters, ornull.
Returns
- A string that is equivalent to the
sourcestring except that all instances ofoldValueare replaced withnewValue. - If
oldValueis not found in thesourcestring, the method returns thesourcestring without any changes.
Example
SELECT * FROM String_SplitRemoveEmptyEntries(',ONE,,TWO,,,THREE,,', ',') SELECT * FROM String_SplitRemoveEmptyEntries('1,2,3,4;5;6;:7:8:9', ',;:')
String_SplitRemoveEmptyEntries4k
It is equivalent to String_SplitRemoveEmptyEntries except no NVARCHAR(MAX) parameters; it can be used when input data will never be over 4000 characters as this function offers better performance.
String_SplitRemoveEmptyEntries4k ( @source NVARCHAR (4000), @delimStr NVARCHAR (4000) ) RETURNS TABLE ([Match] NVARCHAR (4000) NULL)
Example
SELECT * FROM String_SplitRemoveEmptyEntries4k(',ONE,,TWO,,,THREE,,', ',') SELECT * FROM String_SplitRemoveEmptyEntries4k('1,2,3,4;5;6;:7:8:9', ',;:')