--可能有外键,要先把关系drop 掉!然后修改字段属性!
alter table dbo.JobTicket
drop constraint DF__jobticket__PctCo__541767F8
go
Alter Table JobTicket ALTER COLUMN PctComplete int NULL
alter table dbo.JobTicket
drop constraint DF__jobticket__PctCo__541767F8
go
Alter Table JobTicket ALTER COLUMN PctComplete int NULL
drop constraint 约束名最后一步:修改列属性,就应该可以啦alter table 表名
alter column 列名 int
需要把这个Default约束先去掉,然后才能修改这个Column对象
T-SQL脚本同[zlp321002(职业-->烧人民币)]如下:
alter table dbo.JobTicket
drop constraint DF__jobticket__PctCo__541767F8
go
Alter Table JobTicket ALTER COLUMN PctComplete int NULL
ALTER TABLE dbo.VariousJoinTest
ADD PctComplete decimal default(0.0)
Alter Table VariousJoinTest ALTER COLUMN PctComplete int NULL2 得到相同的错误信息,
Server: Msg 5074, Level 16, State 1, Line 3
The object 'DF__jobticket__PctCo__541767F8' is dependent on column 'PctComplete'.
Server: Msg 4922, Level 16, State 1, Line 3
ALTER TABLE ALTER COLUMN PctComplete failed because one or more objects access this column.3 执行如下脚本就好了啊
alter table dbo.JobTicket
drop constraint DF__jobticket__PctCo__541767F8
go
Alter Table JobTicket ALTER COLUMN PctComplete int NULL