日期:2014-05-18 浏览次数:20611 次
如果你一定要用触发器,可如下: CREATE TRIGGER insertOfTimeOn$_SILO_STATES ON dps.SILO_STATES for INSERT AS BEGIN SET NOCOUNT ON update dps.SILO_STATES set IN_START_TIME = (case when i.IN_START_TIME = '1900-01-01 12:00:00.000' then null else IN_START_TIME end), IN_END_TIME = (case when i.IN_END_TIME = '1900-01-01 12:00:00.000' then null else IN_END_TIME end) from dps.SILO_STATES m , inserted i where m.关键字 = i.关键字 END
------解决方案--------------------
create trigger tr_SILO_STATES on SILO_STATES after insert as begin if exists(select 1 from inserted where IN_START_TIME='1900-01-01 12:00:00.000') begin update a set a.IN_START_TIME=null from SILO_STATES a inner join inserted b on a.[主键字段]=b.[主键字段] and b.IN_START_TIME='1900-01-01 12:00:00.000' end end
------解决方案--------------------