数据库:SQL SERVER2008
sql:
use FtnMaterial--数据库名字
go
--HmcpPurPlanComm表增加RetailPrice字段。
IF EXISTS (
SELECT 1 FROM SYSOBJECTS T1
INNER JOIN SYSCOLUMNS T2 ON T1.ID=T2.ID
WHERE T1.NAME='HmcpPurPlanComm' AND T2.NAME='RetailPrice'
)
begin
PRINT '存在'
end
else
begin
begin tran
alter table HmcpPurPlanComm
add RetailPrice decimal(12,4)
--添加字段说明
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'销售价历史记录,提交后才有' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HmcpPurPlanComm', @level2type=N'COLUMN',@level2name=N'RetailPrice'
commit tran
end