How to remove a column from an existing table?

·

·

,

This example is simple. Let’s remove the created column in existing table.

1.Just add a new column to an existing table in your database. 2 Remove it by using following scripts.

 

USE TEST

GO

ALTER TABLE [TEST].[dbo].[TABLE3] ADD [NAME] NVARCHAR(20)

GO

IF EXISTS( SELECTTOP 1 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE  [TABLE_NAME]=‘TABLE3’  AND [COLUMN_NAME] =‘NAME’)

BEGIN

ALTERTABLE [dbo].[TABLE3]

DROPCOLUMN [NAME]

END



Leave a Reply

Your email address will not be published. Required fields are marked *