--2021.03.16 

if not exists(select * from syscolumns where name = 'BCE01C' and object_Name(id)='PGH1')
alter table PGH1 add  BCE01C  int 
GO
if not exists(select * from syscolumns where name = 'BCE03C' and object_Name(id)='PGH1')
alter table PGH1 add  BCE03C  varchar(20)
GO
if not exists(select * from syscolumns where name = 'PGH17' and object_Name(id)='PGH1')
alter table PGH1 add  PGH17 datetime
GO


--2021.04.06 
if not exists(select * from syscolumns where name = 'SCF48' and object_Name(id)='SCF1')
  alter table SCF1 add  SCF48  datetime 
GO
-----------------20210714------------------------------------------------------------------------
if not exists(select * from syscolumns where id=object_id('MBO1') and name='AdjustPurDiff')
alter table MBO1 add AdjustPurDiff numeric(18, 6)
go
-----------------20210722------------------------------------------------------------------------
if not exists(select * from syscolumns where id=object_id('DSA2') and name='BidBarNo')
alter table DSA2 add BidBarNo varchar(64)
go
if not exists(select * from syscolumns where id=object_id('DSA2') and name='BidItems')
alter table DSA2 add BidItems varchar(128)
go
-----------------20210729------------------------------------------------------------------------
if not exists(select * from syscolumns where id=object_id('DTA1_2'))
select * into DTA1_2 from DTA1 where 1=2
go
if not exists(select * from syscolumns where id=object_id('MSW1_2'))
select * into MSW1_2 from MSW1 where 1=2
go
-----------------20210722------------------------------------------------------------------------
if not exists(select * from syscolumns where id=object_id('MDA1') and name='OldBillID')
alter table MDA1 add OldBillID varchar(250)
go
if not exists(select * from syscolumns where id=object_id('MDA1') and name='AllBillID')
alter table MDA1 add AllBillID varchar(250)
go
if not exists(select * from syscolumns where id=object_id('DPA1') and name='OldBillID')
alter table DPA1 add OldBillID varchar(250)
go
if not exists(select * from syscolumns where id=object_id('DPA1') and name='AllBillID')
alter table DPA1 add AllBillID varchar(250)
go
if not exists(select * from syscolumns where id=object_id('MDA3'))
select * into MDA3 from MDA1 where 1=2
go
if not exists(select * from syscolumns where id=object_id('MDA4'))
select * into MDA4 from MDA2 where 1=2
go
if not exists(select * from syscolumns where id=object_id('DPA3'))
select * into DPA3 from DPA1 where 1=2
go
if not exists(select * from syscolumns where id=object_id('DPA4'))
select * into DPA4 from DPA2 where 1=2
go

--视图.V_DPD2_FULL

ALTER VIEW [V_DPD2_FULL]
AS
select ID, BCK01, BillID, xRowNum, BBY01, Unit, PackSize, BatchNo, Quantity, PurchasePrice, PurchaseAmount, RetailPrice, RetailAmount, CostPrice, CostAmount, VAA01, VAJ01, VAJ09, VAJ32, VAJ33, VAJ36, VAJ37, VAJ38, DPK_ID, Remark,  BarNo, PresellPrice, PresellAmount, BBY06, BBY53, BBY60 
from DPD2
UNION ALL
select ID, BCK01, BillID, xRowNum, BBY01, Unit, PackSize, BatchNo, Quantity, PurchasePrice, PurchaseAmount, RetailPrice, RetailAmount, CostPrice, CostAmount, VAA01, VAJ01, VAJ09, VAJ32, VAJ33, VAJ36, VAJ37, VAJ38, DPK_ID, Remark, BarNo, PresellPrice, PresellAmount, BBY06, BBY53, BBY60 
from DPD2_2

GO
if not exists(select * from syscolumns where name = 'CCK02' and object_Name(id)='CCK1')
  alter table CCK1 add CCK02 int  
go
alter table VFS1 alter column BBY53 varchar(50)
alter table VFS1_2 alter column BBY53 varchar(50)
GO
