sqlserver exists 與 in 的區別
使用 EXISTS 方式
select * from A a where EXISTS(select b.mainInfoId from B b where b.mainInfoId=a.mainInfoId);
使用 in 方式
select * from A where id in (select id from B);
sqlserver 將查詢結果以為指定形式分割
#stuff函數
stuff(character_expression,start,length,replaceWith_expression)
刪除指起始位置(start)指定長度(length)的字符,並在該位置插入代替的字符(replaceWith_expression)
#將查詢結果拼接成以逗號分隔的字符串--每條數據以逗號分隔
select stuff(( select ','+ requestid from nccombinedpayment for xml path('')),1,1,'') as requestid ;
