我写了一个存储过程,执行完毕之后,总是会出现warning,如下:
Warning: Null value is eliminated by an aggregate or other SET operation.
执行结果完全正确
但现在有个问题就是,放到程序里运行,经常会出现超时报错,是不是跟warning有关系呢?怎样才可以不出现warning?
解决问题马上结贴,在线等。
不用理它,反正结果是正确的。
这个在用动态SQL时常见。
超时:
1:企业管理器->服务器->属性->连接->查询超时(改为0或一个较大的数)
2:ADO的连接超时属性connectiontimeout 设大点.
3:ADO的CommandTimeout设大点
--改成这样就不会有警告了,不过改不改的结果都一样,个人觉得没必要改.
declare @sql varchar(5000)
select @sql = insert into pre_temp select +@rand++ as random,type,1 as type1,0 as total
select @sql = @sql + ,sum(case m when +m+ then isnull(qty,0) else 0 end) [+m+]+
from (select distinct m from #pre_temp) as a
select @sql = @sql+ from #pre_temp group by type
exec(@sql)
drop table #pre_temp