根據結果集 合併字符串

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.OutBoundLinIdblog

 

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

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

SELECT STUFF('abcdef', 2, 3, 'ijklmn')
GOimg

下面是結果集di

aijklmnefco

相關文章
相關標籤/搜索