• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

delete a column from a table in SQL

I don't remember the SQL syntax for delete a column !
0
verly
Asked:
verly
1 Solution
 
Victor SpiridonovCommented:
There is NO SQL syntax to delete a column from SQL Server table. The only way to do it is:
1. Rename Table
2.  Create new table with one column less
3. Insert data from renamed table into new table
4 Drop renamed table.
use IDENTITY_INSERT  ON/OFF if you inserting data into table with IDENITY column
0
 
verlyAuthor Commented:
40 points because your response arrived fast !
0
 
josephfluckigerCommented:
this appears to no longer be the case. Using Microsoft SQL server 2000. This statement worked for me:

ALTER TABLE MyTable DROP MyColumn
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
arbertCommented:
I like it when people accept stupid answers....
0
 
josephfluckigerCommented:
:)
0
 
JohnDesautelsCommented:
joseph,

Your syntax didn't work for me.

I needed to use DROP COLUMN vs just DROP:

ALTER TABLE MyTable DROP COLUMN MyColumn

I found it at:

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_21127678.html?query=delete+column+from+table&topics=42 

John
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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