无法在 sql server 中将空值插入日期时间 [英] Cannot insert null into datetime in sql server
问题描述
我试图将我的查询中的空值插入到允许空值的日期时间列中.我的查询工作正常(我认为).但是它将 1900-01-01 00:00:00.000 而不是 null 放入日期时间列.为什么会发生这种情况,我该如何解决?
I am trying to insert null with my query into a datetime column which allows null. My query works fine (I think). But its putting 1900-01-01 00:00:00.000 instead of null into the datetime column. Why is this happening and how do I fix it ?
我创建了自己的表来测试这一点,并且在那里归零不是问题.但是,这是另一个数据库中的问题.我想这一定是与其他数据库有关.
I created my own table to test this and nulling is NOT a problem there. But, it is a problem in another database. I think it must be something to do with the other database.
推荐答案
要查看数据库中的所有触发器,请使用以下查询:
To see all the triggers in the database, use the following query:
select
t.name as [TableName],
tr.name as [TriggerName],
m.[definition]
from sys.triggers tr
join sys.sql_modules m on m.object_id = tr.object_id
join sys.tables t on t.object_id = tr.parent_id
要查看所有默认约束,请使用以下查询:
To see all the default constraints, use the following query:
select
t.name as [TableName],
c.name as [ColumnName],
dc.[name] as [ConstraintName],
dc.[definition]
from sys.tables t
join sys.columns c on c.object_id = t.object_id
join sys.objects do on do.object_id = c.default_object_id
join sys.default_constraints dc on dc.object_id= do.object_id
这篇关于无法在 sql server 中将空值插入日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!