码迷,mamicode.com
首页 > 其他好文 > 详细

stuff使用感悟

时间:2018-07-31 22:06:45      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:convert   font   varchar   from   not   var   arch   name   user   

 

select 
STUFF((select ,+Convert(varchar(10),t2.CityId) from t t2 where not exists(
select top 1 1 from Web_UserCity uc where UserName=user001 and uc.CityId=t2.CityId
 ) for xml path(‘‘)) ,1,1,‘‘)
cityIds2
from t
where not exists(
select top 1 1 from Web_UserCity uc where UserName=user001 and uc.CityId=t2.CityId
 )

注意假如表中只有一个字段时,写stuff时,不要盲目乱加条件。

stuff使用感悟

标签:convert   font   varchar   from   not   var   arch   name   user   

原文地址:https://www.cnblogs.com/Tpf386/p/9397908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!