Begin
Drop Function dbo.UdfSplitStringToTable
End
/*
Function That return Table using split with specified char from string
e.g:
Select * From dbo.UdfSplitStringToTable('1¶2¶3¶4','¶')
*/
Go
Create Function dbo.UdfSplitStringToTable
(
@String varchar(max),
@char char(1)
)
Returns @Result Table(Item Varchar(max))
As
Begin
Declare @xDoc XML
Set @xDoc = '
+ Replace(@String,@char,'
+'
Insert Into @Result
Select T2.Loc.value('.','Varchar(max)')
From
@xDoc.nodes('/Ids/Id') As T2(Loc)
Return
End