--把CSupplierCode列是null值的更改为“”
update TDayInStorage set CSupplierCode='' where CSupplierCode is null
go
--更改列非空
alter table TDayInStorage
alter column CSupplierCode char(5) not null
go
--删除表中的联合主键
ALTER TABLE TDayInStorage DROP CONSTRAINT [PK_TDayInStorage]
go
--增加联合主键
ALTER TABLE TDayInStorage ADD CONSTRAINT [PK_TDayInStorage] PRIMARY KEY
(CMaterialCode,CSupplierCode,CInTime,CFactoryCode)
go
--增加列非空,并且第一次插入时间为当前日-1天
alter table TDayInStorage
add CreateDateTime Datetime not null default(getDate()-1)
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)