思迅商云系列按供应商查询流水有数据,销售报表无数据SQL语句
问题原因是商品转换新供应商时没有删除掉旧供应商对应关系导致,请备份数据库后执行以下语句重新生成商品与供应商对应关系表。
use hbposv8
--删除商品与供应商关系表
delete t_bd_supcust_item
go
--重新生成这部分商品与供应商关系表
insert into t_bd_supcust_item(item_no,branch_no,supcust_no,sale_way)
select item_no,(select sys_var_value from t_sys_system where sys_var_id like '%g_branch_no%') as branch_no,main_supcust,item_sup_flag from t_bd_item_info where not exists(select * from t_bd_supcust_item where (item_no =t_bd_item_info.item_no) and (supcust_no = t_bd_item_info.main_supcust) and branch_no =(select sys_var_value from t_sys_system where sys_var_id like '%g_branch_no%' ))
--更新日汇总数据
update t_rm_daysum set supcust_no=t_bd_item_info.main_supcust from t_bd_item_info
where t_rm_daysum.item_no=t_bd_item_info.item_no