未设置默认值的字段,预设写入即为null值,无需设置.-- 查找数据库中所有未设置默认值的字段 select a.name 'table_name', b.name 'column_name' from sys.tables a inner join sys.columns b on a.[object_id]=b.[object_id] left join sys.default_constraints h on b.[object_id]=h.parent_object_id and b.column_id=h.parent_column_id where h.name is null
select a.name 'table_name',
b.name 'column_name'
from sys.tables a
inner join sys.columns b on a.[object_id]=b.[object_id]
left join sys.default_constraints h on b.[object_id]=h.parent_object_id and b.column_id=h.parent_column_id
where h.name is null