如果能够得到存储过程结果集的表结构
insert into #tmp exec sp_who
否则
select * into #tmp from OPENROWSET(
'SQLOLEDB',
'SERVER=server;uid=sa;pwd=sapwd;Database=master','exec 存储过程名') as a
如果存储过程中用到临时表,要用set fmtonly off
select * into #tmp from OPENROWSET(
'SQLOLEDB',
'SERVER=server;uid=sa;pwd=sapwd;Database=master','SET FMTONLY OFF; exec 存储过程名') as a
博客介绍了获取存储过程结果集表结构的方法。若能直接获取,可用insert into #tmp exec sp_who;否则使用select * into #tmp from OPENROWSET语句。若存储过程用到临时表,需用set fmtonly off并在OPENROWSET语句中添加该设置。

587

被折叠的 条评论
为什么被折叠?



