这样可以实现的,
select * into #tmp from OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=poka;UID=sa;PWD=','exec YourDB.dbo.YourProc')
select * into #tmp from OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=poka;UID=sa;PWD=','exec YourDB.dbo.YourProc')
不过sql server的函数也有好多限制,总之,对于你提的这种情况不是很好处理!
存储过程1:
create procedure proc1 @TableName1 varchar(30) as
execute(' select * from ' + TableName1)
--执行表上的操作,当然全部都是动态SQL。然后在proc2中这样调用
create procedure proc2 @TableName1 varchar(30) as
--得到表的结果
select * from syscolumns where id = (select id from sysobjects where name = @TableName1)
exec('select * into #temp1 from ' + @TableName1)
后面的exec(...)为什么不用函数呢?
就这样就可以
insert into #tmp select * from dbo.Functionname(para1,para2)