Quick Search

Transact-SQL: Deleting a Column

July 13th, 2010 by admin
Leave a reply »

 

To delete a column using code, first open or access an empty query window, and use the following syntax:

ALTER TABLE TableName
DROP COLUMN ColumnName

On the right side of the ALTER TABLE expression, type the name of the table. On the right side of the DROP COLUMN expression, enter the name of the undesired column. Here is an example:

ALTER TABLE Members
DROP COLUMN CurrentResidence;
GO

When this code is executed, the interpreter will look for a column named CurrentResidence in a table named Members of the current or selected database. If it finds that column, it will remove it from the table.

Posted in Database

You can follow any responses to this entry through the RSS 2.0 Feed. You can leave a response , or trackback from your own site.

1 commentAdd your comment
  1. physical therapist says:

    Wow this is a great resource.. I’m enjoying it.. good article

 

Leave a Reply