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