select count(1) as 是否过期 
from 
(select filldate from cardfill
 union all
 select filldate from cardfilldate
 union all
 select indate from mainsavetable 
) a
where  filldate > getdate()--try

解决方案 »

  1.   

    一般来说不建议使用函数 用石头哥的 select count(1) as 是否过期 
    from 
    (select filldate from cardfill 
    union all 
    select filldate from cardfilldate 
    union all 
    select indate from mainsavetable 
    ) a 
    where  filldate > getdate() 
      

  2.   

    TRY:select count(1) as 是否过期
    from
    (
    select filldate from cardfill
    union all
    select filldate from cardfilldate
    union all
    select indate from mainsavetable
    ) A
    where filldate>getdate()
      

  3.   

    select sum(cnt) from
    (select cnt=count(1) from cardfill where filldate > getdate()
    union all
    select count(1) from cardfilldate  where filldate > getdate()
    union all
    select count(1) from mainsavetable where indate > getdate()
    ) t
      

  4.   

    函数
    CREATE FUNCTION CheckOutDay ()
    Returns int
    AS
    Begin 
    declare @isout int
    select @isout =count(1) from cardfill cf where cf.filldate > dbo.getdate()
    if(@isout = 0)
    select @isout = count(1) from cardfilldate cfd where cfd.filldate > dbo.getdate()
    if(@isout = 0)
    select @isout =  count(1) from mainsavetable m where m.indate > dbo.getdate()
    Return @isout
    End
      

  5.   


    /******
    这个完全没有问题,我测过了,不知道你,怎么不过!
    ******/CREATE FUNCTION CheckOutDay ()
    Returns int
    AS
    Begin 
    declare @isout int
    select @isout =count(1) from cardfill cf where cf.filldate > getdate()
    if(@isout = 0)
    select @isout = count(1) from cardfilldate cfd where cfd.filldate > getdate()
    if(@isout = 0)
    select @isout =  count(1) from mainsavetable m where m.indate > getdate()
    Return @isout
    End
      

  6.   

    select sum(cnt) from
    (select cnt=count(1) from cardfill where filldate > getdate()
    union all
    select count(1) from cardfilldate  where filldate > getdate()
    union all
    select count(1) from mainsavetable where indate > getdate()
    ) t
    大家动手快多了
      

  7.   

    貌似跟环境有关。
    sql2005中,函数内部可以用getdate()。
    LZ是sql2000?
      

  8.   


    嗯,是sql 2000……貌似大家都用2005了……失败呀~
      

  9.   

    haha,没什么,
    sql版的一帮老鸟都用sql2000,一样玩得出神入化