将表中的字段值作为表名进行查询(如图:ctable)


create proc mytable
@tb varchar(50)
as
exec ('select * from '+@tb)
go
declare @a varchar(50)
--set @a='fitemss98'
select @a=ctable from fitem where i_id=1
exec mytable @a
go

浙公网安备 33010602011771号