-- 更新单据数据(采购发票) 功能：收付款协议升级脚本
if exists(select 1 from @u8db..syscolumns where id =( select id from @u8db..sysobjects where name ='purbillvouch' and xtype ='u')
	and name ='dcreditstart' )
	and 
	exists(select 1 from @t6db..syscolumns where id =( select id from @t6db..sysobjects where name ='purbillvouch' and xtype ='u')
	and name ='cAccountPDate' )
 begin
 exec('
	update a set bcredit=1,cvenpuomprotocol = ''999'',dCreditStart = a.dPBVDate,iCreditPeriod = 0,dGatheringDate=b.cAccountPDate
	from @u8db..purbillvouch a inner join @t6db..purbillvouch b on a.PBVID = b.PBVID
	where isnull(b.cAccountPDate,'''') <>''''')
end
GO
