sql >> Database >  >> RDS >> Sqlserver

TSQL Combineren van meerdere rijen in één rij

declare @T table (FileID int, ErrorCode int, ErrorDesc varchar(max), ErrorCount int)

insert into @T values
(1,             4,                    'Bad File Name',          3),
(2,             6,                    'Bad File Code',          56),
(3,             4,                    'Bad File Name',          2),
(3,             12,                   'Line Length Invalid',    3),
(3,             17,                   'Missing Req Fields',     150)

select FileID,
       (select cast(ErrorCode as varchar(10))+' '+ErrorDesc+' '+cast(ErrorCount as varchar(10))+' '
        from @T as T2
        where T1.FileID = T2.FileID
        for xml path(''), type).value('.', 'varchar(max)') 
from @T as T1
group by FileID


  1. Resamplen op tijdreeksgegevens

  2. FieldShield SDK

  3. Kubernetes kopieert geen gegevens naar gekoppeld volume

  4. Android:SQLite bespaart stringarray?