[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

How to drop a column

How can I drop a column in a table. "ALTER TABLE xxx DROP COLUMN yyy" is not working (i.e. Error 170; Wrong Syntax at yyy). I'm using MS-SQL 6.5 SP3 (at the very beginning).
0
mehl
Asked:
mehl
  • 2
1 Solution
 
tschill120198Commented:
You can't drop a column... you need to create a second table that matches the first (without the column you want to drop), select data from the original table into the second, drop the original table, and then rename the second table (and add the indexes, FKs, etc.).
0
 
mehlAuthor Commented:
Thank you for your fast answer. Sad to see that MS SQL doesn't support DROP COLUMN (some other SQL Servers do). It's always the same with MS billshit. :-)
0
 
tschill120198Commented:
Well, MS isn't the only one to not support it... Sybase and Oracle don't either.  The workaround is easy enough, and dropping a column shouldn't be that common.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now