1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[SQL] SQL UNION multiple COLUMNS into ONE

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 21, 2021.

  1. Stack

    Stack Membro Participativo

    I have this table in SQL Server 2019:

    ID Col1 Col2 Col3
    1 A B C
    2 D
    3 E F G
    4 H I
    5 J


    And I need something like this:

    ID Col1
    1 A
    2 B
    3 C
    4 D
    5 E
    6 F
    7 G
    8 H
    9 I
    10 J


    The number of columns in the source is not fixed, some rows may have only 1 column but others may have up to like 10, 11, etc. Which functions that I need to apply to achieve the result?

    Thanks

    Continue reading...

Compartilhe esta Página