CREATE FUNCTION DismemberStr
(
	@ValueString varchar(4000),
	@DivStr varchar(5)
)
RETURNS @returntable TABLE
(
	FV VARCHAR(50)
)
AS
BEGIN
    DECLARE @P1 INT, @P2 INT
	DECLARE @STR VARCHAR(50) 

	IF SUBSTRING(@ValueString, LEN(@ValueString), 1)<> @DivStr
	  SET @ValueString = @ValueString + @DivStr


	SET @STR = ''

	SET @P1 = 1
	SET @P2 = CHARINDEX(@DivStr, @ValueString, @p1)
	

		WHILE (@P2 > 0)
		BEGIN
			SET @STR = SUBSTRING(@ValueString, @P1, @P2 - @P1)
			IF @STR <> ''
			INSERT INTO @returntable(FV) VALUES(@STR)

			SET @P1 = @P2 + 1
			SET @P2 = CHARINDEX(@DivStr, @ValueString, @p1)
		END
	
	RETURN 
END