IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'CF_Split') 
                   and type = 'TF')
BEGIN
    DROP FUNCTION CF_Split
END
GO


CREATE FUNCTION CF_Split (@String VARCHAR(MAX), @separator VARCHAR(10))


RETURNS @rtnTable TABLE
  (
  Id INT IDENTITY(1,1),
  ColumnA VARCHAR(MAX)
  )
 AS
BEGIN
    DECLARE @position INT = 0;
    DECLARE @endAt INT = 0;
    DECLARE @tempString VARCHAR(MAX);
    
    set @String = ltrim(rtrim(@String));

    WHILE @position<=LEN(@String)
    BEGIN       
        SET @endAt = CHARINDEX(@separator,@String,@position);
        IF (@endAt=0)
        BEGIN
            INSERT INTO @rtnTable(ColumnA) SELECT SUBSTRING(@String,@position,LEN(@String)-@position + 1);
            BREAK;
        END;
        SET @tempString = SUBSTRING(LTRIM(RTRIM(@String)),@position,@endAt-@position);

        INSERT INTO @rtnTable(ColumnA) SELECT @tempString;
        SET @position=@endAt+1;
    END;
    RETURN;
END;


/*

SELECT * FROM  dbo.CF_Split('nada@nada.com;nada@nada.com',';')


*/