有没有方法再存储过程中实现根据变量访问不同的表?
例如根据变量@tabelname
如果是1 则select * from tabel1
如果是2 则select * from tabel2,
......
(不用下面的方式
if (tabelname=1)
select * from tabel1
if (tabelname=2)
select * from tabel2
.......
)
(
我本来是想这样:
declare @tabelname nvarchar(50)
select * from @tabelname
但好像在存储过程中不能这样写!
)