select im_item.item_no,
'['+
REPLACE(
REPLACE(
REPLACE(
REPLACE(
(select barcod_id, barcod from im_barcod where item_no = im_item.item_no and barcod_id is not null
for xml raw)
,'/><row barcod_id=','},{"type": ')
,'<row barcod_id=','{"type": ')
,'barcod=',', "value": ')
,'/>','}')
+']'
as barcod_json
from im_item inner join im_barcod
on im_item.item_no = im_barcod.item_no