日期:2014-05-18  浏览次数:20558 次

SQL语句修改表结构,如图所示

这个表,主键,由工程名改成了工程ID,有3个字段的字符串长度由50变成了max,怎么改啊?

------解决方案--------------------
SQL code

alter table Project drop constraint DF_ID
alter table Project add constraint [新约束名] primary key([列名])

------解决方案--------------------
竟然没一个会的……
DECLARE @Constraint_Name varchar (200)

select @Constraint_Name = Name
from dbo.sysobjects
where Xtype = 'PK'
and Parent_Obj = (select [ID]
from dbo.sysobjects
where id = object_id(N'admin')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)

EXEC ('alter table admin drop constraint '+@Constraint_Name )