我有日期时间字段,当空白日期值添加后自动设置为Jan 1 1900 12:00AM
或1\1\1900
我该如何避免这些。
以下是我用于更新[MOUNT DATE]
字段
[MOUNT DATE] =
CASE WHEN T1.[ROUTING]='L&P' then ''
END
ELSE T1.[A-MOUNT BY]
END
FROM WO T1
INNER JOIN inserted i ON T1.[WO#] = i.[WO#]
END
答案 0 :(得分:-1)
而不是''使用NULL
[MOUNT DATE] =
CASE WHEN T1.[ROUTING]='L&P' then NULL
END
ELSE T1.[A-MOUNT BY]
END
FROM WO T1
INNER JOIN inserted i ON T1.[WO#] = i.[WO#]
END
通过此示例程序进行测试
create table #temp1
(
mydate date null
)
insert #temp1 values (getdate())
select * from #temp1
update #temp1 set mydate = NULL
select * from #temp1
drop table #temp1