首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

select 赋值的简单有关问题,

2012-01-21 
select 赋值的简单问题,在线等…… createtablet2(id1int,lastdatedatetime)insertintot2(id1)values(1)gode

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
*/

热点排行
Bad Request.