码迷,mamicode.com
首页 > 数据库 > 详细

SQLSERVER 检查字段值域并输出行数和值列表

时间:2015-07-31 23:25:42      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

select * from 
(
SELECT 
‘C_DILEI‘ as fen,‘地类‘ as fcn,
‘NVARCHAR‘as ftype,
‘2‘as flen,
(
SELECT count(1) FROM xbmbd WHERE len(ISNULL(C_DILEI,‘‘)) > 2 
) as rnum,
(
SELECT CAST(C_DILEI AS VARCHAR(50))+‘,‘ FROM xbmbd WHERE len(ISNULL(C_DILEI,‘‘)) > 2 GROUP BY C_DILEI ORDER BY C_DILEI for xml path(‘‘)
 ) as fval
) t where fval is not null

输出结果如下:

技术分享

SQLSERVER 检查字段值域并输出行数和值列表

标签:

原文地址:http://www.cnblogs.com/janehlp/p/4693337.html

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