在SQL Server 2000的SQL查询分析器中输入:
create table test ( text char(5) unique);
alter table test drop unique (text)
按下F5运行
错误提示:
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'unique' 附近有语法错误。我的目的是删除test表中text字段的unique。代码照书上写的,第二行无法执行。请给我第二行的正确代码。

解决方案 »

  1.   

    alter table test drop CONSTRAINT 约束名
      

  2.   

    alter table test drop constraint 约束名 --删除约束alter table test drop column     列名   --删除列
      

  3.   

    问题没有解决,请以以下代码为例修改出能执行的语句,问题解决再加25分,谢谢!
    create table test ( txt char(5) unique);
    alter table test drop unique (txt)
      

  4.   

    是不是因为生成的约束是类似“UQ__test__37A5467C”这种形式的所以无法直接根据表名和列名删除呢?那么我如何用SQL语句获得这个约束名呢?
      

  5.   

    我想用VB.NET 2003完成这个操作,如何只使用SQL语言实现?