Try this one:
CREATE FUNCTION [dbo].[SplitIndex](@Delimiter varchar(20) = ' ', @Search varchar(max), @index int)
RETURNS varchar(max)
AS
BEGIN
DECLARE @ix int,
@pos int,
@rt varchar(max)
DECLARE @tb TABLE (Val varchar(max), id int identity(1,1))
SET @ix = 1
SET @pos = 1
WHILE @ix <= LEN(@search) + 1 BEGIN
SET @ix = CHARINDEX(@Delimiter, @Search, @ix)
IF @ix = 0
SET @ix = LEN(@Search)
ELSE
SET @ix = @ix - 1
INSERT INTO @tb
SELECT SUBSTRING(@Search, @pos, @ix - @pos + 1)
SET @ix = @ix + 2
SET @pos = @ix
END
SELECT @Rt = Val FROM @Tb WHERE id = @index
RETURN @Rt
END
Use like so:
SELECT dbo.SplitIndex(' ', 'hello World', 1)
Combine that with Dems answer and you should be good to go
(Note it will return NULL if the specified index does not exist)
e.g.
SELECT dbo.SplitIndex(' ', 'Hello World', 3)
would return NULL because index 3 does not exist
Not sure what performance is like though, I just modified a table valued split function that I'd done so it might be worth rewriting to be more like the MySql version