For me @sdrzymala is correct here. I would normalise this data first before loading it to a database. If the client or report needed the data pivoted or denormalised again I would do this in client code.
1) First I would save the following split function and staging table "PercentsNormalised" into the database. I got the split function from this question here.
-- DDL Code:
Create FUNCTION dbo.SplitStrings
(
@List NVARCHAR(MAX),
@Delimiter NVARCHAR(255)
)
RETURNS TABLE
AS
RETURN (SELECT Number = ROW_NUMBER() OVER (ORDER BY Number),
Item FROM (SELECT Number, Item = LTRIM(RTRIM(SUBSTRING(@List, Number,
CHARINDEX(@Delimiter, @List + @Delimiter, Number) - Number)))
FROM (SELECT ROW_NUMBER() OVER (ORDER BY s1.[object_id])
FROM sys.all_objects AS s1 CROSS APPLY sys.all_objects) AS n(Number)
WHERE Number <= CONVERT(INT, LEN(@List))
AND SUBSTRING(@Delimiter + @List, Number, 1) = @Delimiter
) AS y);
GO
Create Table PercentsNormalised(
RowIndex Int,
-- Other fields here,
PercentValue Varchar(100)
)
GO
2) Either writing some SQL (like below) or using the same logic in a SSIS dataflow task transform the data like so and insert into the "PercentsNormalised" table created above.
With TestData As (
-- Replace with "real table" containing concatenated rows
Select '3%+2%+1%' As Percents Union All
Select '5%+1%+1%+0%' Union All
Select '10%+8%' Union All
Select '10%+5%+1%+1%+0%'
),
TestDataWithRowIndex As (
-- You might want to order the rows by another field
-- in the "real table"
Select Row_Number() Over (Order By Percents) As RowIndex,
Percents
From TestData
)
-- You could remove this insert and select and have the logic in a
-- SSIS Dataflow task
Insert PercentsNormalised
Select td.RowIndex,
ss.Item As PercentValue
From TestDataWithRowIndex As td
Cross Apply dbo.SplitStrings(td.Percents, '+') ss;
3) Write client code on the "PercentsNormalised" table using say the SQL pivot operator.