最后以行写错了!
应该是:
1  2002-3-12  null  tmp1

解决方案 »

  1.   

    TRY:
    1,建立序数表
    select top 8000 identity(int,1,1) as N into numtab from 
    (select top 100 id=1  from sysobjects) as a,
    (select top 100 id=1  from sysobjects) as b,
    (select top 100 id=1  from sysobjects) as c示,select a.a,a.b+N,a.c,a.d from 
    (select * from table where c is not null)a
    left join Num b on a.c-a.b>=b.N
    Union all
    select * from table where c is null
      

  2.   

    TRY:忘了你的BC字段可能不是日期型了。:)
    select a.a,cast(a.b as datetime)+N,a.c,a.d from 
    (select * from table where c is not null)a
    left join Num b on cast(a.c as datetime)-cast(a.b as datetime)>=b.N
    Union all
    select * from table where c is null
      

  3.   

    调试正确的代码:select top 8000 identity(int,0,1) as N into num from 
    (select top 100 id=1  from sysobjects) as a,
    (select top 100 id=1  from sysobjects) as b,
    (select top 100 id=1  from sysobjects) as c
    select a.a,convert(char(10),cast(a.b as datetime)+N ,120) b,a.c,a.d from 
    (select * from table where c is not null)a
    left join Num b on cast(a.c as datetime)-cast(a.b as datetime)>=b.N
    Union all
    select * from table where c is null
      

  4.   

    可否解释一下!比如:第一个查询怎么和我的table1没什么关系?可以解释一下吗?
    我不想把代码拷贝来就用!谢谢!
      

  5.   

    时间变化我搞定了!谢谢高手赐教!可否问一问您是怎么对SQL这么熟悉!可以指个方向!!!谢谢!