(2006-04-22 15:48:22)   【MsSQL】NetJu(17571611)谁知道这个怎么写呀!!
gzbhid fdate
1111 2006-01-02 
1111 2006-01-10要求结果:
1111 2006-01-02
1111 2006-01-03
.
.
1111 2006-01-09
1111 2006-01-10

解决方案 »

  1.   

    ISNULL()
    EXISTS()
    NOT EXISTS()
    IS NULL()
    NOT IS NULL()
      

  2.   

    create table ss1(gzbhid varchar(10),fdate datetime)
    --执行语句
    declare @a datetime,@b datetime,@i int
    select @a='2006-01-02'
    select @b='2006-01-10'
    select @i=datediff(d,@a,@b)
    while @i>=0
     begin
     insert ss1 select '1111',@a
     select @a=dateadd(d,1,@a)
     select @i=datediff(d,@a,@b)
     end
    select * from ss1
    --删表
    drop table ss1
      

  3.   

    --取数据库
    create table ss(gzbhid varchar(10),fdate datetime)
    insert ss select '1111','2006-01-02'
    insert ss select '1111','2006-01-10'
    --建表
    create table ss1(gzbhid varchar(10),fdate datetime)
    --执行语句
    declare @a datetime,@b datetime,@i int
    select @a=min(fdate) from ss where gzbhid='1111'
    select @b=max(fdate) from ss where gzbhid='1111'
    select @i=datediff(d,@a,@b)
    while @i>=0
     begin
     insert ss1 select '1111',@a
     select @a=dateadd(d,1,@a)
     select @i=datediff(d,@a,@b)
     end
    select * from ss1
    --删表
    drop table ss1
    drop table ss
      

  4.   

    declare @dDate datetime,@EndDate datetime
    set @dDate='2006-04-12'
    set @EndDate='2006-04-21'
    while @dDate<=@EndDatebegin
       set @dDate=DateAdd(day,1,@dDate)
       select convert(varchar(10),@dDate,120)
    end
      

  5.   

    哎呀! 谢谢个位大哥,但是我不是这个意思..我想用一条select就来搞定!