er为字段添加默认值

er为字段添加默认值

SQL Server为字段添加默认值

if not exists (
select *
from sys.columns as c
join sys.objects as o on c.default_object_id = o.[object_id]
where c.[object_id] = object_id('DriverTable')
and c.name = 'DriverVan'
)
begin
alter table DriverTable
add default(0) for DriverVan
with values
end
else
print 'default value for DriverVan exists'
go
04-23 02:27