error in STRING_SPLIT


  • Hello everyone
    Who has an idea please about the exact error of the STRING_SPLIT command
    CREATE TABLE [dbo].[StagingTable](
        [ProductId] [varchar](50) NOT NULL,
        [PartsList] [varchar](1000) NOT NULL
        )
    GO

    INSERT INTO dbo.StagingTable
    (ProductId,PartsList)
    VALUES
    (1,'463|914|771|281|418'),
    (2,'422|453'),
    (3,'323|724|449|882|591|715')

    select * from StagingTable
    cross apply STRING_SPLIT(PartsList,'|')

    while the requested result is following
    1 463
    1 914
    1 771
    1 281
    1 418
    2 422
    2 453
    3 323
    3 449
    3 882
    3 591
    3 715

    thanks

  • joujousagem2006 1602 - Monday, August 13, 2018 9:47 AM


    Hello everyone
    Who has an idea please about the exact error of the STRING_SPLIT command
    CREATE TABLE [dbo].[StagingTable](
        [ProductId] [varchar](50) NOT NULL,
        [PartsList] [varchar](1000) NOT NULL
        )
    GO

    INSERT INTO dbo.StagingTable
    (ProductId,PartsList)
    VALUES
    (1,'463|914|771|281|418'),
    (2,'422|453'),
    (3,'323|724|449|882|591|715')

    select * from StagingTable
    cross apply STRING_SPLIT(PartsList,'|')

    while the requested result is following
    1 463
    1 914
    1 771
    1 281
    1 418
    2 422
    2 453
    3 323
    3 449
    3 882
    3 591
    3 715

    thanks

    So what is the error?

  • joujousagem2006 1602 - Monday, August 13, 2018 9:47 AM


    Hello everyone
    Who has an idea please about the exact error of the STRING_SPLIT command
    CREATE TABLE [dbo].[StagingTable](
        [ProductId] [varchar](50) NOT NULL,
        [PartsList] [varchar](1000) NOT NULL
        )
    GO

    INSERT INTO dbo.StagingTable
    (ProductId,PartsList)
    VALUES
    (1,'463|914|771|281|418'),
    (2,'422|453'),
    (3,'323|724|449|882|591|715')

    select * from StagingTable
    cross apply STRING_SPLIT(PartsList,'|')

    while the requested result is following
    1 463
    1 914
    1 771
    1 281
    1 418
    2 422
    2 453
    3 323
    3 449
    3 882
    3 591
    3 715

    thanks

    Something looks missing, I get 13 rows, the same as the number of elements whilst you are saying that you only get 12 rows?
    😎

    Can you post the results of
    SELECT @@VERSION
    please?

  • I have this result 

    I am with the sql version 2017

  • joujousagem2006 1602 - Monday, August 13, 2018 10:06 AM

    I have this result 

    I am with the sql version 2017

    What result?  I see nothing.

  • joujousagem2006 1602 - Monday, August 13, 2018 10:06 AM

    I have this result 

    I am with the sql version 2017

    What's wrong with that output? I don't see an error there.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Monday, August 13, 2018 10:10 AM

    joujousagem2006 1602 - Monday, August 13, 2018 10:06 AM

    I have this result 

    I am with the sql version 2017

    What's wrong with that output? I don't see an error there.

    it's my fault sorry
    after 8 hours of work I lose my concentration

  • And now the image is visible.

  • joujousagem2006 1602 - Monday, August 13, 2018 10:15 AM

    it's my fault sorry

    after 8 hours of work I lose my concentration

    You're doing well. Takes me about 12 minutes.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply