Duplicate and Split Row based on value by using SQL Query?

后端 未结 2 1729
自闭症患者
自闭症患者 2021-01-17 06:01

I have set of data and wants to split multiple rows based on the column value.

For Example,

Source Data:

Expected Output:

T

2条回答
  •  自闭症患者
    2021-01-17 06:47

    The Best and Simple way to solve above is

    Select value as UID, Name ,Age ,Education ,Department

    from StackSoln

    Cross apply string_split(UID,',')

    STRING_SPLIT

    A table-valued function that splits a string into rows of substrings, based on a specified separator character.

    CROSS APPLY

    returns only rows from the outer table that produce a result set from the table-valued function. It other words, result of CROSS APPLY doesn't contain any row of left side table expression for which no result is obtained from right side table expression. CROSS APPLY work as a row by row INNER JOIN

提交回复
热议问题