SQL Server为字段添加默认值

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
posted @ 2017-10-05 16:41  CooMark  阅读(8679)  评论(0编辑  收藏  举报