先在约束表的salarey中删除users中'DF_Users_salary'有的值.
或先删除约束.

解决方案 »

  1.   

    ALTER TABLE DROP  CONSTRAINT DF_Users_salary
    ALTER TABLE DROP COLUMN salary
      

  2.   

    if object_id('test')>0 
    drop table test
    go
    create table test(id int not null,age int null default(20))
    go
    insert test(id) select 1
    insert test select 2,22
    go
    select * from test
    /*
    id age
    1 20
    2 22
    */declare @table sysname,@col sysname,@constraint_name sysname
    select @table='test',@col='age'
    select @constraint_name=b.name from sys.syscolumns a
     join sys.sysobjects b on a.cdefault=b.id
     where object_id(@table)=a.id and a.name=@col and a.cdefault>0
    if @constraint_name is not null
    exec('alter table test drop '+@constraint_name)alter table test drop column age
    go
    select * from test
    /*
    id
    1
    2
    */