if 	exists(select 1 from @t6db..syscolumns where id =( select id from @t6db..sysobjects where name ='rdrecord' and xtype ='u')
	and name ='itaxrate' )
begin
	 if exists (select 1 from @u8db..sysobjects where name ='rdrecord01' and xtype ='u')
	 begin   
	  exec('update  a set a.itaxrate = b.itaxrate from  @u8db..rdrecord01 a inner join  @t6db..rdrecord b on a.id = b.id  where a.cvouchtype =''01''')
		exec('update  a set a.itaxrate = b.itaxrate ,
				  a.ioritaxcost = b.itaxcost,             
				  a.ioritaxprice = b.itaxprice,
				  a.iorisum = b.isum,
				  a.isum = b.isum,
				  a.itaxprice = b.itaxprice
		   from   @u8db..rdrecords01 a inner join  @t6db..rdrecords b on a.id = b.id and a.autoid = b.autoid 
							inner join @u8db..rdrecord01 h  on a.id = h.id where h.cvouchtype =''01'' and isnull(a.itaxrate,0) = 0')
	  end            

	else
	 begin
	 if exists(select 1 from @u8db..syscolumns where id =( select id from @u8db..sysobjects where name ='rdrecord' and xtype ='u')
		and name ='itaxrate' )
	 begin  
		 exec('update  a set a.itaxrate = b.itaxrate from  @u8db..rdrecord a inner join  @t6db..rdrecord b on a.id = b.id  where a.cvouchtype =''01''')
		 exec('update  a set a.itaxrate = b.itaxrate ,
					  a.ioritaxcost = b.itaxcost,             
					  a.ioritaxprice = b.itaxprice,
					  a.iorisum = b.isum,
					  a.isum = b.isum,
					  a.itaxprice = b.itaxprice
			   from   @u8db..rdrecords a inner join  @t6db..rdrecords b on a.id = b.id and a.autoid = b.autoid 
								inner join @u8db..rdrecord h  on a.id = h.id where h.cvouchtype =''01'' and isnull(a.itaxrate,0) = 0')
	  end        
	end
end
go

