Subscribe to this thread
Home - Cutting Edge / All posts - how to drop multiple columns from a table
samuelgj27 post(s)
#21-Sep-22 00:20

Manifold version 8

I am trying to delete multiple columns (around 100+) from many tables (50+) with this

ALTER TABLE [Customers]

DROP COLUMN [ContactName], [adress], ....

but it dont work

Any sugestion?

tjhb

9,993 post(s)
#21-Sep-22 00:59

For a column (or field), the syntax is not DROP COLUMN but just DROP. You can then add a list of fields to drop all at once.

Other operations, such as DROP INDEX, do take an extra token.

[Edit]

I half put you crook. Yes, just DROP. But you must repeat DROP for each field to be removed (with commas in between). A bare list of fields to drop is not valid.

So

ALTER TABLE [Customers]

(

DROP [Name],

DROP [address],

)

;

If that is not convenient, you might prefer to SELECT INTO a new table.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.