select branch_no,branch_name,property,branch_man,address,zip,branch_email,branch_tel,branch_fax,display_flag,area,trade_type,com_grant,account,com_init,init_date,indep_bal,dc_no,com_date_up,com_date_down,com_oper_up,com_oper_down
from #SDB..t_bd_branch_info
where (case when (#TV = 'isszmv9'  and (branch_no in ('000','000001') or len(branch_no) = 3)) or ((#TV = 'isszmv6' or #TV = 'isszmv7' or #TV = 'isszmv8' or #TV = 'isszmv9') and branch_no in ('000','000001'))
	   then '0' else '1' end) = '1'
##
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_branch_info set price_type = tab_a.price_type,price_rate = tab_a.price_rate
		from #SDB..t_bd_branch_info as tab_a
		where t_bd_branch_info.branch_no = tab_a.branch_no')
GO
if (#TV = 'hbposv8')
	exec('update t_bd_branch_info set dm_cost = ''1'' where isnull(dm_cost,'''') = ''''')
GO
if (#SV = 'hbposev8' or #SV = 'hbposev9') and
	(#TV = 'hbposev8' or #TV = 'hbposev9')
	exec('update t_bd_branch_info set yh_branch_no = tab_a.yh_branch_no
	from #SDB..t_bd_branch_info as tab_a
	where t_bd_branch_info.branch_no = tab_a.branch_no')
GO
if not (#SV = 'isszmv6' or #SV = 'isszmv7' or #SV = 'isszmv8' or #SV = 'isszmv9' or #TV = 'isszmv6' or #TV = 'isszmv7' or #TV = 'isszmv8' or #TV = 'isszmv9')
	exec('update t_bd_branch_info set other1 = tab_a.other1,
									  other2 = tab_a.other2,
									  other3 = tab_a.other3,
									  sheet_tag = tab_a.sheet_tag,
									  check_flag = tab_a.check_flag,
									  check_sheet_no = tab_a.check_sheet_no,
									  check_branch_no = tab_a.check_branch_no
		  from #SDB..t_bd_branch_info as tab_a
		  where t_bd_branch_info.branch_no = tab_a.branch_no')
GO