create proc selectName
as
begin
declare @sql varchar(100)
declare @name varchar(20)
select @name = name from sysobjects where xtype='U' and id=373576369
print @name
set @sql='select * from '+ @name --拼接
exec (@sql)
end
exec selectName --执行
仅供参考!
select 'select * from '|| c.fhistablename || ';'
from t_hr_cmpsheme c
where c.fname_12 like '%薪酬%'
and c.fhistablename is not null;