--------------更改一个主键的列的类型的步骤------------------------------------
例如:修改表GBTerminal.F97列xh类型为smallint --删除默认值
alter table GBTerminal.F97 drop constraint DF_F97_xh
go
--删除check
alter table GBTerminal.F97 drop constraint [CK_f97_xh]
go
--删除主键
alter table GBTerminal.F97 drop constraint PK_F97
go
--更改xh列类型为smallint
alter table GBTerminal.F97 alter column xh int NOT NULL
--xh列加默认值
alter table GBTerminal.F97 add constraint DF_F97_xh default(0) for xh
--xh列加check约束
alter table [GBTerminal].[F97] add constraint [CK_f97_xh] CHECK (([xh]<=(1024)))
--添加主键PK_F97
alter table GBTerminal.F97 add constraint PK_F97 primary key(tid,xh)