USE MyTestDB
--先删除约束
declare @name varchar(20)
select @name = b.name from sysobjects b join syscolumns a on
b.id = a.cdefault where a.id = object_id('UserInfo') and a.name = 'NickName'
exec('alter table UserInfo drop constraint ' + @name)
--然后再删除字段就OK了
ALTER TABLE dbo.UserInfo DROP COLUMN NickName