SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,675 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Suppose the string values are separated by different delimiters like ',' '&' ';', then could we use string_split in this case?
Hi @Lylyy
could we use string_split in this case?
Yes, you could use Replace to turn these different delimiters to same and then use String_split.
Please check this sample:
DECLARE @string varchar(max) = 'AAA, BBB & CCC DDD;EEE'
SELECT *
FROM STRING_SPLIT(REPLACE(REPLACE(REPLACE(@string,' ',','),';',','),'&',','),',')
WHERE value <> ''
Best regards,
Cosmog Hong