--销售订单 功能：收付款协议升级脚本
if exists(select 1 from @u8db..syscolumns where id =( select id from @u8db..sysobjects where name ='salebillvouch' and xtype ='u')
	and name ='dcreditstart' )
	and 
	exists(select 1 from @t6db..syscolumns where id =( select id from @t6db..sysobjects where name ='salebillvouch' and xtype ='u')
	and name ='cAccountPDate' )
 begin
	exec('update a set bcredit=1,cgatheringplan = ''999'',dCreditStart = a.ddate,icreditdays = 0,dGatheringDate=b.cAccountPDate
	from @u8db..salebillvouch a inner join @t6db..salebillvouch b on a.sbvid = b.sbvid
	where isnull(b.cAccountPDate,N'''') <>N''''')
end
if exists(select 1 from @u8db..syscolumns where id =( select id from @u8db..sysobjects where name ='dispatchlist' and xtype ='u')
	and name ='dcreditstart' )
	and 
	exists(select 1 from @t6db..syscolumns where id =( select id from @t6db..sysobjects where name ='dispatchlist' and xtype ='u')
	and name ='cAccountPDate' )
 begin
	--销售发货单 功能：收付款协议升级脚本
	exec('update a set bcredit=0,cgatheringplan = ''999'',dcreditstart = a.ddate,icreditdays = 0,dgatheringdate=b.cAccountPDate
	from @u8db..dispatchlist a inner join @t6db..dispatchlist b on a.dlid = b.dlid
	where isnull(b.cAccountPDate,N'''') <>N''''')
 end
GO
