SQl 表名是变量

用另一个变量保存要执行的SQL语句
然后用exec执行该变量




declare  @strsql varchar(50),
        @table_name varchar(50)
set @table_name='test'       --test是表名
set @strsql='select count(*) from '+@table_name
exec(@strsql)

猜你喜欢

转载自blog.csdn.net/suheonline/article/details/25966555