SQL 2005 Overflow: Compound Column Value

xiaoxiao2021-04-08  430

- Example Data Declare @t Table (ID INT, Value Varchar (10)) Insert @t Select 1, 'Aa'Union All Select 2,' Aaa'Union All Select 2, 'BBB 'Union All SELECT 2,' CCC '

- Query processing Select * from (Select Distinct IDFROM @T) AOUTER Apply (SELECT [VALUES] = Stuff (Replace (Replace (Select Value from @t nwhere id = a.idfor xml auto), ' ','), 1, 1, '))

/ * - Result ID VALUES -------------------------- 1 AA, BB2 AAA, BBB, CCC

(2 lines affected) - * /

转载请注明原文地址:https://www.9cbs.com/read-132759.html

New Post(0)