用isdate(),isnumeric()检查一下相关的字段

解决方案 »

  1.   

    select NE, StartTime,Type,sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat 
    --本身语法就有问题
    --你的语句有没有贴完整
      

  2.   

    我怕太长了(select NE, Type,convert(varchar (20),StartTime,120) AS StartTime isdate(),sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat where StartTime >= dateadd(hour,-24,getdate()) group by NE,StartTime,Type) union (select NE,StartTime,'所有' as Type,sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat where StartTime >= dateadd(hour,-24,getdate()) group by NE,StartTime) order by NE,StartTime desc,Type
      

  3.   

    用这个试下
    cast(startdate of smalldatetime)
      

  4.   

    我怕太长了(select NE, Type,convert(varchar (20),StartTime,120) AS StartTime isdate(),sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat where StartTime >= dateadd(hour,-24,getdate()) group by NE,StartTime,Type) union (select NE,StartTime,'所有' as Type,sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat where StartTime >= dateadd(hour,-24,getdate()) group by NE,StartTime) order by NE,StartTime desc,Type ---------
    红色部分什么意思?
      

  5.   

    --try
    select NE, convert(varchar (20),StartTime,120) AS StartTime,Type,sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat.....where isdate(StartTime)=1 
      

  6.   

    这样:
    --我怕太长了
    (select NE, Type,convert(varchar (20),StartTime,120) AS StartTime isdate(),sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat where StartTime >= dateadd(hour,-24,getdate()) group by NE,StartTime,Type) union (select NE,StartTime,'所有' as Type,sum(UsrReg) as UsrReg from UndcHistory.dbo.HLRHourStat where StartTime >= dateadd(hour,-24,getdate()) group by NE,StartTime) order by NE,Star…
      

  7.   

    这样用法怎么可能对?
    AS StartTime isdate()
    -->as StartTime --isdate()去掉,在条件中where isdate(StartTime)=1
    看看
      

  8.   

    try:(select NE, [Type],convert(varchar (20),StartTime,120) AS StartTime,sum(UsrReg) as UsrReg 
    from UndcHistory.dbo.HLRHourStat 
    where StartTime >= dateadd(hour,-24,getdate())
    group by NE,StartTime,Type) 
    union 
    (select NE,'所有' as [Type],StartTime,sum(UsrReg) as UsrReg 
    from UndcHistory.dbo.HLRHourStat 
    where StartTime >= dateadd(hour,-24,getdate()) 
    group by NE,StartTime) 
    order by NE,StartTime desc,Type
    union 连接的两个结果集的列必须一一对应,类型也必须一致。
    你把字符型和smalldatetime型对应,当然会报错。
      

  9.   

      行了谢谢  因为我想转换时间但在flex里显示为格林xx时间 我只转换了前面的 后面没转就不行了