你的PLANDATE什么字段类型的啦?我下面的是PLANDATE VARCAR(10)
方法一:
create trigger sdate
on table1
for update,insert
as
set nocount on
declare @sdate varchar(10)
select @sdate=convert(varchar(10),getdate(),120)
update table1 set plandate=case when inserted.plandate<@sdate then @sdate else inserted.plandate end
from table1,inserted where table1.id=inserted.id
方法二:
create trigger sdate
on table1
for update,insert
as
set nocount on
declare @sdate varchar(10)
select @sdate=convert(varchar(10),getdate(),120)
update table1 set plandate=@sdate
from table1,inserted where table1.id=inserted.id
and inserted.plandate<@sdate