select type_id,type_name,sale_way,discount,memo,oper_id,oper_date,acc_flag,acc_amt,sale_amt,saving_flag from #SDB..t_rm_vip_type
##
if (#SV = 'isszmv6' or #SV = 'isszmv7' or #SV = 'isszmv8' or #SV = 'isszmv9') and (#TV = 'isszmv6' or #TV = 'isszmv7' or #TV = 'isszmv8' or #TV = 'isszmv9')
	exec('update t_rm_vip_type set limit_times = tab_a.limit_times,
								   card_type = tab_a.card_type,
								   ic_type = tab_a.ic_type,
								   item_flag = tab_a.item_flag,
								   update_acc = tab_a.update_acc,
								   update_amt = tab_a.update_amt 
		  from #SDB..t_rm_vip_type as tab_a
		  where t_rm_vip_type.type_id = tab_a.type_id')
else
	exec('update t_rm_vip_type set other1 = tab_a.other1,
								   other2 = tab_a.other2,
								   other3 = tab_a.other3,
								   memo1 = tab_a.memo1,
								   memo2 = tab_a.memo2,
								   memo3 = tab_a.memo3 
		  from #SDB..t_rm_vip_type as tab_a
		  where t_rm_vip_type.type_id = tab_a.type_id')
GO