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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM