IF EXISTS(SELECT 1 FROM MASTER..SYSOBJECTS WHERE NAME = 'PDropColumn' AND TYPE = 'P') BEGIN DROP PROC dbo.PDropColumn END GO CREATE PROC dbo.PDropColumn ( @table varchar(100), @column varchar(100) ) AS BEGIN DECLARE @Sql VARCHAR(2000) -- DECLARE @Table VARCHAR(200) -- DECLARE @Column VARCHAR(200) -- SELECT @Table = 'TEmployee' -- SELECT @Column = 'FGender' SELECT @sql = ' ALTER TABLE ' + @Table + ' DROP CONSTRAINT ' + OBJECT_NAME(A.constid) + '' FROM SYSCONSTRAINTS AS A ,syscolumns AS C WHERE A.id = OBJECT_ID(@Table) AND A.id = C.id AND A.colid = C.colid AND A.id = OBJECT_ID(@Table) AND C.name = @Column IF @@ROWCOUNT > 0 BEGIN EXEC (@Sql) PRINT @sql END SELECT @Sql = ' ALTER TABLE ' + @Table + ' DROP COLUMN ' + @Column EXEC (@Sql) END GO select 'EXEC PDropColumn ' + object_name(id) + ' , ' + name FROM syscolumns WHERE Name IN( 'FMasterId','FId','FNo','FFromChild','FCourseId','FPayTypeId','FItemId','FMemId','FPayTypeId','FEmpId','FCardId','FCardTypeId','FGoodsId','FUnitId') DROP TABLE TInventory