存储过程的表名是不确定的,能不能用字符串拼接啊

flyingsky2008 flyingsky2008 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
create proc P_CRE_TMP
@startDate date, @endDate date
as
begin
declare @date date, @mess varchar(50)
select @date =@startDate
while @date<=@endDate
begin
insert into TJ_PB_ARRIVE_PJ_TAB
select Fld_Print_Date,
S.Fld_Station_Code,
count(*) 批,
sum(Fld_Num) 件
from IQ_BAG_INDEX_TAB_2011 I
join V_STATION_ALL_TAB S on S.Fld_Station_Code = I.Fld_Arrive_Station_Code and S.Fld_Filiale_Code in (select Fld_Filiale_Code from FILIALE_TAB where Fld_Flag<>'9')
where Fld_Print_Date = convert(char(8),@date,112)
and Fld_Waste_Code = '0'
and Fld_Ticket_Type in ('0','1')
group by Fld_Print_Date,S.Fld_Station_Code

select @mess = convert(char(8),@date,112)
print @mess
select @date = dateadd(dd,1,@date)
commit
end
end;
上面的那个IQ_BAG_INDEX_TAB_2011表我想报年份改成我输入的参数。怎么改啊。。。
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部
flyingsky2008
MS-SQL Server 34,876 成员 254,635 内容