想根据输入表名,执行不同的操作
--设表a 和 B字段个数,类型都可以不一样
create table a ( cola int , colb varchar(4))
create table b ( col2a int ,col2b varchar(3))
go
insert into a values(2, 'erew ')
insert into b values(33, 'kdj ')
----怎样
declare @strtabname varchar(30)
set @strtabname = 'a '
select * from @strtabname
------解决方案--------------------declare @strtabname varchar(30)
set @strtabname = 'a '
--select * from @strtabname
exec ( 'select * from '+@strtabname)