[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

delete a column from a table in SQL

Posted on 1998-06-24
6
Medium Priority
?
569 Views
Last Modified: 2012-05-07
I don't remember the SQL syntax for delete a column !
0
Comment
Question by:verly
[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
6 Comments
 
LVL 7

Accepted Solution

by:
Victor Spiridonov earned 150 total points
ID: 1091615
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
ID: 1091616
40 points because your response arrived fast !
0
 
LVL 1

Expert Comment

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

ALTER TABLE MyTable DROP MyColumn
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 34

Expert Comment

by:arbert
ID: 9900484
I like it when people accept stupid answers....
0
 
LVL 1

Expert Comment

by:josephfluckiger
ID: 9900500
:)
0
 
LVL 6

Expert Comment

by:JohnDesautels
ID: 12484028
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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

649 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