如何解决----警告: 聚合或其它SET 操作消除了空值. 我在做统计行数的时候,使用了count()函数,还要把结果插入到另一张表中去但是出现了警告: 聚合或其它SET 操作消除了空值.语句为:select count(*) into Bfrom A 请问如何解决? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是因为有的行的字段内容为 null 值, 聚合函数会忽略值为 null 的行,所以,count(*) 统计的值不含这些行在内。 那该如何忽略那些为null的字段, declare @t table(ID int,[Name] varchar(10))insert @t select null,nullinsert @t select 1,nullinsert @t select null,'A'select count(isnull(id,0))[count] into # from @tselect count(id)[count] into ## from @tselect * from #select * from ##drop table #drop table ##(1 行受影响)count-----------3(1 行受影响)count-----------1(1 行受影响) SET ANSI_WARNINGS Off;---在語句前加入INSERT T SELECT COL... 在count()的时候,不计算空值的 select count(isnull(字段,'')) into B from A cont()函数我不能确定表里是那个字段为null所以使用isnull()没有作用 select count(*) into B from Awhere A.a >10 加上这个条件之后,如何使用isnull() set ansi_warnings off 谢谢了问题解决了set ansi_warnings off 是对的 sqlserver 2008的一个小问题!!!!在线等 无法将类型为System.DBNull的对象强制转换为类型System.Int32 如何提高数据库索引的效率 2次使用动态SQL 关于Select之后锁住资源的问题! 如何编号啊? 导入excel问题 如何将ACCESs的库导入SQL SEVER? 两表有同一字段的和并 请教SQL语句 sql中能否实现下面要求? 如何为临时表创建自动增长字段?
聚合函数会忽略值为 null 的行,所以,count(*) 统计的值不含这些行在内。
insert @t select null,null
insert @t select 1,null
insert @t select null,'A'
select count(isnull(id,0))[count] into # from @t
select count(id)[count] into ## from @t
select * from #
select * from ##
drop table #
drop table ##(1 行受影响)
count
-----------
3(1 行受影响)count
-----------
1(1 行受影响)
---在語句前加入
INSERT T SELECT COL...
from A
我不能确定表里是那个字段为null
所以使用isnull()没有作用
from A
where A.a >10
加上这个条件之后,
如何使用isnull()
set ansi_warnings off
问题解决了
set ansi_warnings off
是对的