存储过程按日期参数查询对应分表

sql server表名由年月+tabel组成,如202101_table ,202102_table ,202103_table

create proc test
as
begin
Declare @Date1 varchar(50),@Date2 varchar(50)
Set @Date1=Convert(varchar(8),DATEADD(dd,-1,getdate()),112)
Set @Date2=@Date1
select ordernum from xxxxxx_table where OccurDate >= @Date1 and OccurDate <=@Date2
end

运行结果及报错内容
我的解答思路和尝试过的方法

怎么根据@Date2或者@Date1 查询对应的表,例如今天是20211010,查对应的202110_table表