select supcust_no,supcust_flag,sup_name,region_no,sup_type,sup_man,sup_addr,zip,sup_email,sup_tel,sup_fax,sup_acct_back,sup_acct_no,sup_tax_no,display_flag,check_out_flag,check_out_date,check_out_day,credit_amt,sub_no,pay_flag,order_flag,purchase_day,po_cycle,acc_level,reg_type,oper_id,purchase_week,sale_way,shopcard,modify_date,settle_branch,com_flag,mobile from #SDB..t_bd_supcust_info
##
if (#SV = 'hbposv6' or #SV = 'hbposv7' or #SV = 'hbposv8' or #SV = 'hbposev8' or #SV = 'hbposev9') and
	(#TV = 'hbposv6' or #TV = 'hbposv7' or #TV = 'hbposv8' or #TV = 'hbposev8' or #TV = 'hbposev9')
	exec('update t_bd_supcust_info set sup_ly_amt = isnull(tab_a.sup_ly_amt,0)
			from #SDB..t_bd_supcust_info as tab_a
			where t_bd_supcust_info.supcust_no = tab_a.supcust_no')
GO
if (#SV = 'hbposv7' or #SV = 'hbposv8' or #SV = 'hbposev8' or #SV = 'hbposev9') and
	(#TV = 'hbposv7' or #TV = 'hbposv8' or #TV = 'hbposev8' or #TV = 'hbposev9')
	exec('update t_bd_supcust_info set cust_clsno = tab_a.cust_clsno
			from #SDB..t_bd_supcust_info as tab_a
			where t_bd_supcust_info.supcust_no = tab_a.supcust_no')
GO
if (#SV = 'hbposev8' or #SV = 'hbposev9') and
	(#TV = 'hbposev8' or #TV = 'hbposev9')
	exec('update t_bd_supcust_info set sup_ly_rate = isnull(tab_a.sup_ly_rate,0),
									   valid_date = tab_a.valid_date
			from #SDB..t_bd_supcust_info as tab_a
			where t_bd_supcust_info.supcust_no = tab_a.supcust_no')
GO
if (#SV = 'isszmv6' or #SV = 'isszmv7' or #SV = 'isszmv8' or #SV = 'isszmv9') and (#TV = 'isszmv7' or #TV = 'isszmv8' or #TV = 'isszmv9')
	if #SV = 'isszmv6' 
		exec('update t_bd_supcust_info set discount = isnull(tab_a.discount,0)
				from #SDB..t_bd_supcust_info as tab_a
				where t_bd_supcust_info.supcust_no = tab_a.supcust_no')
	else
		exec('update t_bd_supcust_info set discount = isnull(tab_a.discount,0),
										   memo = tab_a.memo
				from #SDB..t_bd_supcust_info as tab_a
				where t_bd_supcust_info.supcust_no = tab_a.supcust_no')			

else if (#TV = 'isszmv7' or #TV = 'isszmv8' or #TV = 'isszmv9')
	begin
		exec('update t_bd_supcust_info set memo = tab_a.other3
			from #SDB..t_bd_supcust_info as tab_a
			where t_bd_supcust_info.supcust_no = tab_a.supcust_no')
		exec('update t_bd_supcust_info set discount = 1 where isnull(discount) = 0')
	end
GO

if (#TV = 'isszmv6' or #TV = 'isszmv7' or #TV = 'isszmv8' or #TV = 'isszmv9')
	update t_bd_supcust_info set settle_branch = '0'
else
	update t_bd_supcust_info set settle_branch = '00'
GO