Skip to main content

How to drop a table column in SQL Server.

begin transaction;
set quoted_identifier on;
set arithabort on;
set numeric_roundabort off;
set concat_null_yields_null on;
set ansi_nulls on;
set ansi_padding on;
set ansi_warnings on;
commit;

begin transaction;
go
alter table <dbo>.<tbl_name> drop column <column_name_to_drop>;
go
alter table <dbo>.<tbl_name> set(lock_escalation = table);
go
commit;

---
--- or to check for table and column existence first.
if exists (select * from sys.columns as c
    inner join sys.objects as t
        on c.object_id = t.object_id
    where t.object_id = OBJECT_ID(N'[dbo].[tbl_name]')
        and c.name = 'column_name_to_drop')
    begin
        alter table dbo.tbl_name drop column column_name_to_drop;
    end;
else
    begin
        print N'Table or column does not exist.';
    end;