Deleting columns

  • Sounds simple enough, huh? I'm running SQL 2000 on a development machine. When I try to delete a column through Enterprise Manager or through script, I get an "incorrect syntax error name of column". I have tried it on a couple different machines, and no go. Thanks for the help.

  • Can you post the DDL?

    Steve Jones

    steve@dkranch.net

  • Pardon my ignorance, but what ddl?

  • The sql to create the table you are trying to drop the column from. We can recreate on our machines, see if we have the same issue.

    Andy

  • Ohhh. The table was created in Enterprise Mgr, so all defaults. The columns were datatype int, allow nulls & database char (10), allow nulls. Everything else was default for the columns. Does that help?

  • Almost. We need the script for it. Right click the table and find the option to generate a script. Save that to disk, open it, copy and paste the test into the reply form here.

    Andy

  • is there something strange about the name of the column or any column? like it's got an invalid character in it.

    If you use the profiler you can see what enterprise manager is trying to execute and can probably guess what is wrong.

    Edited by - nigelrivett on 11/30/2001 11:23:48 PM


    Cursors never.
    DTS - only when needed and never to control.

  • Hi

    To delete a column you give

    Alter table table1 drop column colname

    However if you have any constraint on the column like primary key or any other computation ,based on the column you may not be able to delete the column till you have removed the constraint.

    The other thing could be that you probably are using single quotes to enclose the column name,try using double quotes or square brackets

    Lata

  • like

    alter table MyTable drop column [MyColumn]

    Steve Jones

    steve@dkranch.net

  • That the SQL I am trying to use. Tried sq brackets & double quotes. Still get Incorrect syntax error near "name of column".

  • can you post the script that is giving this error?

    Steve Jones

    steve@dkranch.net

  • I tried to generate it, but I get an error 0. I get that all the tables on my development server. I'll see if I can get them off my production server. Does generating the script do anything to the database itself?

  • No, it just writes the definition to a text file.

    Andy

  • Can you just post all the column names? or generate a script for the creation of the table.

    Steve Jones

    steve@dkranch.net

  • The plot thickens. I can delete columns on tables that have been created in other databases. Also, the column will delete when deleting through Visual InterDev. Go figure. Thanks for all your input. I'll have to do some more exploring at this end.

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic. Login to reply