If I have the following code, how can I use it to separate values in a field in my database?
declare @xml xml, @delimited nvarchar(max), @delimiter nvarchar(10)
set @delimited = N'a,b,c,d,e'
set @delimiter = N','
set @xml = N'<root><r>' + replace((SELECT @delimited FOR XML PATH('') ), @delimiter, '</r><r>') + '</r></root>'
select
t.value('.','varchar(max)') as [delimited items]
from @xml.nodes('//root/r') as a(t)
declare @xml xml, @delimited nvarchar(max), @delimiter nvarchar(10)
set @delimited = N'a,b,c,d,e'
set @delimiter = N','
set @xml = N'<root><r>' + replace((SELECT @delimited FOR XML PATH('') ), @delimiter, '</r><r>') + '</r></root>'
select
t.value('.','varchar(max)') as [delimited items]
from @xml.nodes('//root/r') as a(t)