星期五, 5月 07, 2010

使用stuff將多筆記錄合併成一筆並用逗號分隔


select stuff((select ','+user_name From im_chat_log where id in (1, 2) FOR XML PATH('')),1,1,'' ) as xylist