使用sql stuff函數
/* stuff(param1, startIndex, length, param2)
說明:將param1中自startIndex(SQL中都是從1開始,而非0)起,刪除length個字符,然后用param2替換刪掉的字符。*/
示例:
select po_no = stuff((select ';' + 字段 from 表 t where 查詢條件 for xml path('')) , 1 , 1 , '')
使用sql stuff函數
/* stuff(param1, startIndex, length, param2)
說明:將param1中自startIndex(SQL中都是從1開始,而非0)起,刪除length個字符,然后用param2替換刪掉的字符。*/
示例:
select po_no = stuff((select ';' + 字段 from 表 t where 查詢條件 for xml path('')) , 1 , 1 , '')
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。