Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Split a column into multiple rows by multiple search strings

$
0
0

There are many posts about how to split 1 column that contains multiple items separated by a character (for example, separated by ;). My issue is a bit more complex. The string I want to search and separate it's values, can contain the value separated by semicolon, coma, and other characters. Plus, for some rows, it can contain a valid string with no separation characters (in other words only 1 value). Tried different functions found online (using XML, etc.), but no function addresses these features (they only search and splity by 1 substring at a time (Ex. split string by semicolon, etc.), and/or cannot handle occasions where the character being searched for is not found. Here is a sample data :

string to be searched for

---------------------------------------------------------

HD-387837; H-989308, HH-99999

HG-498748

Function should return the following (using the data above) :

-------------------------------------------------------------

HD-387837

H-989308

HH-99999

HG-498748


Adrian Hernandez




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>