2013年6月13日 星期四

SQL多筆資料串成一個字串(欄位)


Select
A.memoYear
,
(
Select '註' + Convert(varchar, memoAliasNo) +':' +Memo +char(13)
From ficEntrustMemo B
Where B.memoYear=A.memoYear --And B.memoNo = A.memoNo
for xml path('')
) as Memo
From ficEntrustMemo A
Group By memoYear