Add/Drop column in SQL Server
Add new column to existing table
IF NOT EXISTS( SELECT 1 FROM information_schema.columns WHERE table_name = 'table_name' AND column_name = 'column_name' )BEGINALTER TABLE table_name ADD column_name VARCHAR(255) NULLENDGO
Remove column from the table
IF EXISTS( SELECT 1 FROM information_schema.columns WHERE table_name = 'table_name' AND column_name = 'column_name' )BEGINALTER TABLE table_name DROP COLUMN column_nameENDGO
Comments
Post a Comment