[personal profile] finesoul

Original article: http://www.kodyaz.com/articles/t-sql-convert-split-delimeted-string-as-rows-using-xml.aspx

ALTER FUNCTION [dbo].[Split] ( @Delimiter varchar(5), @List nvarchar(4000) )
RETURNS @TableOfValues table ( RowID smallint IDENTITY(1,1), [Value] varchar(50))
AS
BEGIN
declare @xml xml
set @xml = N'' + replace(@List, @Delimiter,'') + ''

INSERT INTO @TableOfValues([Value])
select t.value('.','nvarchar(4000)') as [delimited items]
from @xml.nodes('//root/r') as a(t)
RETURN
END
go
-- and the most amazing thing is following
select *
from MappingRunningPrintCode mrpc
CROSS APPLY dbo.split(',', mrpc.RunningPrintCodeList) spl

it gaves you following output.

If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Лютий 2022

Н П В С Ч П С
  12345
6789101112
13141516171819
202122232425 26
2728     

За стиль дякую

Створено з Dreamwidth Studios
Сторінка створена 2025-Чер-20, П'ятниця 09:21