Solved

delete a column from a table in SQL

Posted on 1998-06-24
6
540 Views
Last Modified: 2012-05-07
I don't remember the SQL syntax for delete a column !
0
Comment
Question by:verly
6 Comments
 
LVL 7

Accepted Solution

by:
spiridonov earned 50 total points
Comment Utility
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
 

Author Comment

by:verly
Comment Utility
40 points because your response arrived fast !
0
 
LVL 1

Expert Comment

by:josephfluckiger
Comment Utility
this appears to no longer be the case. Using Microsoft SQL server 2000. This statement worked for me:

ALTER TABLE MyTable DROP MyColumn
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 34

Expert Comment

by:arbert
Comment Utility
I like it when people accept stupid answers....
0
 
LVL 1

Expert Comment

by:josephfluckiger
Comment Utility
:)
0
 
LVL 6

Expert Comment

by:JohnDesautels
Comment Utility
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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now