31
08/12
变量表与临时表的效率分析
昨日一朋友发来一段sql的存储过程(如下),让我看看能不能优化一下。 insert @T1 select g_no,co_no,si_no,str_no,sum(ind_qty) as qty from instock_detail where in_id = @id group by g_no,co_no,si_no,str_no--?unitstock -->保存在变量表中 insert @T2 select a.* from unitstock a,@T1 b where a.g_no =b.g_no and a.co_no =b.co_no and a.si_no =b.si_no and a.str_no=b.str_nodelete unitstock from @T1 a where unitstock.g_no=a.g_no and unitstock.co_no =a.co_no and unitstock.si_no=a.si_...