').value('.','NVARCHAR(MAX)') AS įor example, for the key=2, the xmldata column contains XML of the following structure: is a string parsing based method to get same result. REPLACE(CAST( AS NVARCHAR(MAX)), '') + '' AS XML REPLACE(CAST( AS NVARCHAR(MAX)), '') + '' + SQL - DDL and sample data population, startĭECLARE table( INT PRIMARY KEY, varchar(max), varchar(max), varchar(max), varchar(max)) First, excluding not needed tokens based on their position, Second, generating new string containing tokens that were excluded. Exactly what we need.Ĭonverting column into XML data type and, additionally, constructing an XML fragment with the positions of tokens to exclude.