create table t2(id1 int,lastdate datetime)
insert into t2(id1) values (1)godeclare @date1 datetimeselect @date1=isnull(lastdate,getdate()) from t1 where id1=1
print @date1

解决方案 »

  1.   

    drop table t2
    go
    create table t2(id1 int,lastdate datetime)
    insert into t2(id1) values (1)godeclare @date1 datetimeselect @date1=isnull(lastdate,getdate()) from t2 where id1=1   --表名写错
    print @date1
      

  2.   

    呵呵,不好意思,但是select不能正确执行
      

  3.   

    我的这个select语句是在存储过程中的,不能正确执行,为什么?
      

  4.   

    单独就这一段代码来说,是正确的.
    看是不是你存储过程中哪里有错误!drop table t2
    go
    create table t2(id1 int,lastdate datetime)
    insert into t2(id1) values (1)godeclare @date1 datetimeselect @date1=isnull(lastdate,getdate()) from t2 where id1=1   --表名写错
    print @date1/*(所影响的行数为 1 行)07 20 2007  4:29PM
    */
      

  5.   

    select @date1=(isnull(lastdate,getdate()) from t2 where id1=1)要用括號括起來.