alter table trm_imp_plan_pay
drop column aaaa
呵呵,马虎

解决方案 »

  1.   

    --- PLS test:CREATE TABLE  #doc_exb ( column_a INT, column_b VARCHAR(20) NULL) 
    alter table #doc_exb add aaaa char(4) null
    select * from #doc_exb
    ALTER TABLE  #doc_exb DROP COLUMN aaaa
    select * from #doc_exb
    DROP TABLE  #doc_exb
      

  2.   

    CREATE TABLE doc_exa ( column_a INT) 
    GO
    ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL
    select * from doc_exa
    GO
    alter table doc_exa
           drop column column_b
    GO
    select * from doc_exa
    DROP TABLE doc_exaOK
      

  3.   

    如果是表名的錯誤,也不會提示
    Incorrect syntax near 'aaaa'. 1: 如果沒有該表 :
         Cannot alter table 'yourTablename' because this table does not exist in database 'batest'.
     2: 有該表 但沒有列:
         ALTER TABLE DROP COLUMN failed because column 'aaaa' does not exist in table 'yourTablename'.
      

  4.   

    对不起,是我打错了,是同一张表zb_shipping_invoice
      

  5.   

    呵呵,hjhing(winding)很认真!!楼主试试,Incorrect syntax near 'aaaa'.的提示应该是有些关键字写错了。
      

  6.   

    检查一下你的语法!和列名,表名你定义了主键或其他约束吗??declare @name varchar(20)select @name=b.name from syscolumns a,sysobjects b where a.id=object_id('tablename') and b.id=a.cdefault and a.name='field1' and b.name like 'DF%'exec('alter table tablename drop constraint '+@name) alter table tablename drop column field1
      

  7.   

    CCEO:那句话不就use,go,alter,table,drop,column是关键字吗,在查询分析器中,都是蓝色的,不会有错吧.
    pengdali(大力) :aaaa就是普通的一列,不是主键外键,也没有其他约束.
      

  8.   

    如果要删除主键列
    先要
    alter table table
    drop constraint PK__ttttt__6B79F03D再
    alter table ttttt
    drop column aaaa
      

  9.   

    CREATE TABLE  doc_exb ( column_a INT, column_b VARCHAR(20) NULL) 
    alter table doc_exb add aaaa char(4) null
    select * from doc_exb
    ALTER TABLE  doc_exb DROP COLUMN aaaa
    select * from doc_exb
    DROP TABLE  doc_exbCREATE TABLE  #doc_exb ( column_a INT, column_b VARCHAR(20) NULL) 
    alter table #doc_exb add aaaa char(4) null
    select * from #doc_exb
    ALTER TABLE  #doc_exb DROP COLUMN aaaa
    select * from #doc_exb
    DROP TABLE  #doc_exb两种方法都可以得到想要的结果,你检查一下你的语法或有没有什么限制条件吧