1

I have a string like that "10*cat*123456;12*rat*789;15*horse*365" i want to split it to be like that "cat, rat, horse" I have made this Function

CREATE FUNCTION [dbo].[Split](@BenNames VARCHAR(2000))
RETURNS VARCHAR(2000)
AS
BEGIN
    DECLARE @tmp VARCHAR(2000)
    SET @tmp = @BenNames    
    SET @tmp = SUBSTRING(
            SUBSTRING(@tmp, CHARINDEX('*', @tmp) + 1, LEN(@tmp)),
            0,
            CHARINDEX('*', SUBSTRING(@tmp, CHARINDEX('*', @tmp) + 1, LEN(@tmp)))
        )
    RETURN @tmp    but it only split only one part "10*cat*123456"

i want to send every part to this by another function or another looop

1 Answer 1

1

Have you taken a look at: http://blogs.microsoft.co.il/blogs/itai/archive/2009/02/01/t-sql-split-function.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

sorry all, I didn't give myself time to understand the idea thank you "pb"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.