Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to drop a column

Posted on 1998-12-08
3
Medium Priority
?
298 Views
Last Modified: 2010-03-19
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
Comment
Question by:mehl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
tschill120198 earned 200 total points
ID: 1092151
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
 

Author Comment

by:mehl
ID: 1092152
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
 
LVL 2

Expert Comment

by:tschill120198
ID: 1092153
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question