代码如下:
declare @d_startdate datetime --计算开始的时间
declare @i_week int -- 计算的周数
declare @i int -- 循环变量
declare @c_month varchar(10)
declare @c_othermonth varchar(10)
declare @c_startmonth varchar(10)
declare @c_fcode varchar(10)
declare @d_curdate datetime
declare @c_sql varchar(max)
declare @c_sqlfirst varchar(max)
declare @c_sqlstock varchar(max)
declare @c_othersql varchar(max)
declare @c_sqlcalu varchar(max)
declare @month_name varchar(10)
declare @c_materialcode varchar(30)
set @c_sql = ' if exists ( select 1 from sysobjects where id = object_id(''re_select'') and type = ''U'')
drop table re_select '
set @c_sql = @c_sql + ' select m.*,s.* into re_select '
set @c_sql = @c_sql + ' from ( select a.material_code m_material_code,a.material_name,a.version,
a.purchase_code,a.manufacturer,a.describe,a.material_status,a.unit,
b.*,
a.version_id m_version_id
from ( select distinct b.*
from bom_detail_tb a,base_material_vw b,bom_version_tb c
where a.version_id = b.version_id
and a.bom_id = c.bom_id ) a,