ALTER FUNCTION Split(@str NVARCHAR(MAX),@char NVARCHAR(10)) RETURNS @Array TABLE([Id] INT,[TEXT] NVARCHAR(1000)) AS BEGIN DECLARE @i INT DECLARE @index INT SET @i=0 SET @index=1 WHILE(1=1) BEGIN DECLARE @x INT SET @x=@i SET @i=CHARINDEX(@char,@str,@x) IF @i=0 BEGIN BREAK END ELSE BEGIN INSERT INTO @Array (Id,[Text]) VALUES(@index,substring(@str,@x,@i-@x)) SET @i=@i+1 SET @index=@index+1 END END RETURN END GO SELECT * FROM SPLIT('1~2~3~','~')