if exists (select 1 from @u8db..fa_items  where sid ='250') and 
	exists(select 1 from @u8db..fa_items  where sid ='1500')
begin
	--update a set a.dblAddTax = b.dblOffsetTax ,a.dblValueAndTax = a.dblValue + b.dblOffsetTax  
	--from @u8db..fa_Cards a inner join @t6db..fa_cards b on a.sCardID = b.scardid 
	                
	----将卡片样式中的可抵扣税额字段替换为增值税字段
	--update  @u8db..fa_ItemsOfModel set sItemID = '250' where  sItemID = '1500'
	    
	----删除fa_items中的可抵扣税额字段
	--delete from @u8db..fa_items where  sid = '1500'
	--将原帐套中的可抵扣税额放到增值税字段中，并算出价税合计
	exec ('update a set a.dblAddTax = b.dblOffsetTax ,a.dblValueAndTax = a.dblValue + b.dblOffsetTax  
	from @u8db..fa_Cards a inner join @t6db..fa_cards b on a.sCardID = b.scardid ')

	--将原帐套中的原始累计折旧放到录入时累计折旧字段中
	                
	--将卡片样式中的可抵扣税额字段替换为增值税字段
	update  @u8db..fa_ItemsOfModel set sItemID = '250' where  sItemID = '1500'
	    
	--删除fa_items中的可抵扣税额字段
	delete from @u8db..fa_items where  sid = '1500'
	--删除fa_items中的增值税变动金额字段
	delete from @u8db..fa_items where  sid = '1060'
	--删除fa_items中的变动前价税合计字段
	delete from @u8db..fa_items where  sid = '1061'
	--删除fa_items中的变动后价税合计字段
	delete from @u8db..fa_items where  sid = '1062'
	--删除fa_items中的原始累计折旧字段
	delete from @u8db..fa_items where  sid = '1501'

	
	
	
end 
go
if exists (select 1 from @u8db..syscolumns where id =(select id from @u8db..sysobjects where name ='fa_cards'and XTYPE='u') and name ='dblInputDeprTotal')
	and 
	exists (select 1 from @t6db..syscolumns where id =(select id from @t6db..sysobjects where name ='fa_cards'and XTYPE='u') and name ='dblInputDeprTotal')
begin
 exec ('update a set a.dblInputDeprTotal  = b.dblTransDeprT  
	from @u8db..fa_DeprTransactions a inner join @t6db..fa_cards b on a.sCardnum = b.sCardnum ')
end
go
if exists(select 1 where object_id('tempdb..#fa') is not null)
drop table #fa
select IDENTITY (int,1,1)tmpid,sid,sname ,lQueryOrder into #fa 
	from @u8db..fa_Items b where b.bQuery =1 and b.lQueryOrder>0 
	order by lQueryOrder
 update a  set lQueryOrder =b.tmpid 
	from @u8db..fa_Items a inner join #fa b on a.sid=b.sid and a.sname =b.sname 
		where a.bQuery =1 and a.lQueryOrder>0
    
if exists(select 1 where object_id('tempdb..#fa') is not null)
drop table #fa

go