SQL Server 表增加字段案例语句
IF NOT EXISTS ( SELECT 1 FROM sys.sysobjects (NOLOCK) so INNER JOIN sys.syscolumns (NOLOCK) sc ON so.id = sc.id WHERE so.name = 'EgSys_ActualFreightMain' AND sc.name = 'UpdateBy' ) BEGIN ALTER TABLE dbo.EgSys_ActualFreightMain ADD UpdateBy VARCHAR(50) NOT NULL DEFAULT '' EXEC sys.sp_addextendedproperty @name = N'MS_Description', @value = N'更新人', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'EgSys_ActualFreightMain', @level2type = N'COLUMN', @level2name = N'UpdateBy' END; GO