标签:style blog ar color sp on div 2014 问题
select space(8) as fsrq into #test0 where 0 = 1
declare @fsrq char(8)
set @fsrq=‘20141111‘
while convert(char(8), @fsrq, 112) <= ‘20141211‘
begin
insert #test0 (fsrq) select convert(char(8), @fsrq, 112)
select @fsrq = dateadd(day, 1, @fsrq)
end
select * from #test0
这样一段代码,进入了死循环,把代码改为下面的这种,也是跳不出。
select space(8) as fsrq into #test0 where 0 = 1 declare @fsrq char(8) set @fsrq=‘20141111‘ while @fsrq <= ‘20141211‘ begin insert #test0 (fsrq) select @fsrq select @fsrq = dateadd(day, 1, @fsrq) select @fsrq = convert(char(8),@fsrq,112) end select * from #test0
事实上第一种只要把char(8)换成datetime类型就一点问题都没有。
我是错在哪里了,请指点一二啊
标签:style blog ar color sp on div 2014 问题
原文地址:http://www.cnblogs.com/havenenjoy/p/4166372.html