DECLARE @sample TABLE
(
id INT IDENTITY,
xmlSnippet VARCHAR(MAX)
);
INSERT @sample
(
xmlSnippet
)
VALUES
('<monthdate>2019-07-01</monthdate>
<automitemno>302</automitemno>
<amount>1.190000000000</amount>
<currentamount>0.000000000000</currentamount>
<langitemno>1</langitemno>
<monthdate>2019-07-01</monthdate>
<automitemno>2131</automitemno>
<amount>0.386750000000</amount>
<currentamount>0.000000000000</currentamount>
<langitemno>1<monthdate>');
DECLARE @tempTable TABLE
(
id INT,
XMLValue XML
);
INSERT @tempTable
(
id,
XMLValue
)
SELECT id,
CAST('<monthdate>' + value AS xml)
FROM @sample
CROSS APPLY STRING_SPLIT(REPLACE(xmlSnippet, '<monthdate>', '&'), '&')
WHERE value <> '';
SELECT *
FROM @tempTable;