Это безобразно, как и все, но эй ... Я должен использовать DelimitedSplit8k_LEAD
здесь, что касается второго разделения, порядковая позиция важна. В любом случае это делает "работу", но оставляет одинарные кавычки вокруг значений. Это зависит от вас, чтобы потом исправить.
WITH Pivoted AS(
SELECT V.UndelimitedList,
DSc.ItemNumber,
MAX(CASE DSv.ItemNumber WHEN 1 THEN DSv.Item END) AS ColumnName,
MAX(CASE DSv.ItemNumber WHEN 2 THEN DSv.Item END) AS ItemValue
FROM (VALUES('AutoFill = 1 Backgrouns = True StoreAddress1 = ''1601 River Road East'' StoreAddress2 = '''' StoreCity = ''Kitchener'' StoreProv = ''ON'' StorePostal = ''N2A 3Y4'' StorePhone = ''(844) 607-6362'''))V(UndelimitedList)
CROSS APPLY(VALUES(REPLACE(REPLACE(V.UndelimitedList,' ','|'),' = ','~'))) CL(DelimitedList) --Assumes no values will have a double space, and all are separated by double space
--Also assumes that a Pipe (|) and Tilda (~) will never appear in your data
CROSS APPLY dbo.DelimitedSplit8K_LEAD(CL.DelimitedList,'|') DSc
CROSS APPLY dbo.DelimitedSplit8K_LEAD(DSc.Item,'~') DSv
GROUP BY V.UndelimitedList,
DSc.ItemNumber
HAVING MAX(CASE DSv.ItemNumber WHEN 1 THEN DSv.Item END) != '')
SELECT MAX(CASE P.ColumnName WHEN 'AutoFill' THEN NULLIF(P.ItemValue,'''''') END) AS AutoFill,
MAX(CASE P.ColumnName WHEN 'Backgrouns' THEN NULLIF(P.ItemValue,'''''') END) AS Backgrouns,
MAX(CASE P.ColumnName WHEN 'StoreAddress1' THEN NULLIF(P.ItemValue,'''''') END) AS StoreAddress1,
MAX(CASE P.ColumnName WHEN 'StoreAddress2' THEN NULLIF(P.ItemValue,'''''') END) AS StoreAddress2,
MAX(CASE P.ColumnName WHEN 'StoreCity' THEN NULLIF(P.ItemValue,'''''') END) AS StoreCity,
MAX(CASE P.ColumnName WHEN 'StoreProv' THEN NULLIF(P.ItemValue,'''''') END) AS StoreProv,
MAX(CASE P.ColumnName WHEN 'StorePostal' THEN NULLIF(P.ItemValue,'''''') END) AS StorePostal,
MAX(CASE P.ColumnName WHEN 'StorePhone' THEN NULLIF(P.ItemValue,'''''') END) AS StorePhone
FROM Pivoted P
GROUP BY P.UndelimitedList;
DB <> Fiddle