I'm trying to import data from an excel spreadsheet into a SQL Server 2008 database and I need to massage the data a bit first.
I've used the Data Import wizard to load it into a staging table in the database in the following format:
Id ISOCode Data
1 US Foo
2 CA Bar
3 US or CA Blah
In cases where ISO is an OR-delimited string, eg US or CA
, I need to split it into 2 rows, so in the final destination table it would look like this:
Id ISOCode Data
1 US Foo
2 CA Bar
3 US Blah
3 CA Blah
I do have a SplitString
table-valued function available but I'm not sure how to work it into the equation.