CREATE FUNCTION [dbo].[Split] (
@String [nvarchar](max),@Delimiter [char](1))
RETURNS @temptable TABLE ([items] [nvarchar](max))ASBEGINDECLARE @xml XMLSET @xml = cast(('<Node>'
+ replace(@String, @Delimiter, '</Node><Node>')
+ '</Node>') AS XML)
INSERT INTO @temptableSELECT N.value('.', 'nvarchar(max)') AS itemsRETURN
FROM @xml.nodes('Node') AS T(N)
END