發表文章

目前顯示的是 1月, 2016的文章

[MSSQL] 合併多筆資料至同一欄

圖片
<原始資料>  <SQL執行結果> select ogb01, ogb04, Left(ogb03List, LEN(ogb03List)-1) as ogb03List from ( select distinct ogb01, ogb04, ( select cast(ogb03 as nvarchar) + ',' from ogb_file as ogb2 where ogb2.ogb01='ABC-0001' and ogb2.ogb04=ogb1.ogb04 FOR XML PATH('') ) as ogb03List from ogb_file ogb1 where ogb1.ogb01='ABC-0001' ) A select distinct ogb01, ogb04, substring(( select ',' + cast(ogb03 as nvarchar) from ogb_file as ogb2 where ogb2.ogb01='ABC-0001' and ogb2.ogb04=ogb1.ogb04 FOR XML PATH('') ),2,1000) as ogb03List from ogb_file ogb1 where ogb1.ogb01='ABC-0001'

[Oracle] 合併多筆資料至同一欄

圖片
<原始資料> <SQL執行結果> select ogb01, ogb04, WMSYS.WM_CONCAT(ogb03) as ogb03 from ogb_file where 1=1 and ogb01='ABC-0001' group by ogb01, ogb04

[MSSQL]欄位型態為ntext時中文查不到資料

MSSQL欄位型態為ntext時,若要查用中文查詢時,無法查詢到資料。 SELECT * FROM ATable where A like '%中文字%'; 因為寫入的中文是Unicode,所以where條件要加N來識別,才能查到資料。 SELECT * FROM ATable where A like N'%中文字%'; reference web: http://www.blueshop.com.tw/board/FUM20041006152735ZFS/BRD20050612182713UBP.html