1. 程式人生 > >根據結果集 合並字符串

根據結果集 合並字符串

ima code group by tinc 合並字符串 .com path png ecc

SELECT OutBoundLinId,
STUFF(
(SELECT distinct ‘;‘ + RecCode FROM FI_ARReceivableSheets t
left join FI_ARReceiSheetLines t2 ON t.ReceivableSheetId = t2.ReceivableSheetId
WHERE t2.OutBoundLinId=FI_ARReceiSheetLines.OutBoundLinId FOR XML PATH(‘‘)), 1, 1, ‘‘) AS RecCode
FROM
FI_ARReceiSheetLines
GROUP BY FI_ARReceiSheetLines.OutBoundLinId

技術分享

select RecCode from FI_ARReceivableSheets FOR XML PATH(‘‘) 將結果轉換成XML

技術分享

STUFF 刪除指定長度的字符,並在指定的起點處插入另一組字符。

SELECT STUFF(‘abcdef‘, 2, 3, ‘ijklmn‘)
GO

下面是結果集

aijklmnef

根據結果集 合並字符串