I had to import a large CSV into SQL Server and there are a slew of columns I need to drop but don't want to list them all out or graphically right-click and delete if it's possible to just drop them all in one go.
Editing the CSV won't really work due to it being large and Excel causing some alignment issues.
I've already dropped a few columns by right-clicking and "Delete" both from the Object Explorer as well as via Design; and by using
ALTER TABLE table_name
DROP COLUMN column56, column57, ...
I would like to be able to do something like
DROP COLUMN from column56 to column79
2条答案
按热度按时间hgncfbus1#
If your columns are really numbered (column56, column57, ...) you can use dynamic sql here.
You can also delete columns using the table designer in Sql Server Management Studio ( see delete-columns-from-a-table )
yzxexxkh2#
Try generating the necessary ALTER TABLE statements dynamically from column56 to column79: