日期:2014-05-18  浏览次数:20408 次

表变量是否能作为存储过程的输入参数?
我试了一下,好像报错?

------解决方案--------------------
可以的
http://topic.csdn.net/t/20050118/00/3733325.html
http://topic.csdn.net/t/20050618/21/4091637.html
------解决方案--------------------
楼主说的表变量是
1.
declare @t table(id int)
还是
2.
declare @tbname varchar(20)
set @tbname = 'tablename '
啊?
如果是1的话存储过程不支持,可将数据存到实体表,再将表名传给存储过程.如果2的话支持,例如:
create proc up_test(@tbname varchar(20))
as
exec( 'select * from '+@tbname)
GO
--调用
declare @tbname varchar(20)
set @tbname = 'tablename '
exec up_test @tbname