select '' as item_brandno,'' as item_brandname,'' as item_flag,'' as brand_parent,'' as display_flag,'' as return_rate,'' as comp_rate from sysobjects with(nolock) where 1=2
##
if (#SV = 'isszmv8' or #SV = 'isszmv9') and (#TV = 'isszmv8' or #TV = 'isszmv9')
	begin
		exec('insert into t_bd_item_brand (item_brandno,item_brandname,item_flag,brand_parent,display_flag,return_rate,comp_rate)
			  select item_brandno,item_brandname,item_flag,brand_parent,display_flag,return_rate,comp_rate from #SDB..t_bd_item_brand')
		exec('update t_bd_item_info set item_brand = ''0''+item_brand where len(item_brand) = 1')
	end
else if (not (#SV = 'isszmv8' or #SV = 'isszmv9')) and (#TV = 'isszmv8' or #TV = 'isszmv9')
	begin
		exec('insert into t_bd_item_brand (item_brandno,item_brandname,item_flag,brand_parent)
			  select distinct code_id=case when len(code_id) = 1 then ''0''+code_id else code_id end,code_name,''0'',''NULL'' 
			  from #SDB..t_bd_base_code where type_no=''PP'' and (len(code_id) = 1 or len(code_id) = 2)')
		exec('update t_bd_item_info set item_brand = ''0''+item_brand where len(item_brand) = 1')
	end
		
GO