Solved

How to drop a column

Posted on 1998-12-08
3
287 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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
tschill120198 earned 50 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS - Date Report Options 2 30
MS SQL: Return all results in a single row separated by commas 1 27
sql server query 18 42
Help With SQL Query 9 33
I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

821 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