参照一下:
http://expert.csdn.net/Expert/topic/3016/3016902.xml?temp=.9715082
问题提出:ghosthjt (天煞孤星)
解答:Yang_(扬帆破浪), j9988(j9988)如果能够方便的得到存储过程结果集的表结构。那存储过程的使用就方便了很多了。比如:
insert into #tmp exec sp_who
要执行这一句,前提必须知道sp_who的结果集的表结构。
这样的语句又不能运行:select * into #tmp from exec sp_who解答:
1:
select * into #z from OPENROWSET(
'SQLOLEDB',
'SERVER=server;uid=sa;pwd=sapwd;Database=master','exec sp_who') as a2: 如果存储过程中用到临时表,要用set fmtonly off
select * into #z from OPENROWSET(
'SQLOLEDB',
'SERVER=server;uid=sa;pwd=sapwd;Database=master','SET FMTONLY OFF; exec 存储过程名') as a
-----------------------
或把结果集插入到临时表,然后再关联
http://expert.csdn.net/Expert/topic/3016/3016902.xml?temp=.9715082
问题提出:ghosthjt (天煞孤星)
解答:Yang_(扬帆破浪), j9988(j9988)如果能够方便的得到存储过程结果集的表结构。那存储过程的使用就方便了很多了。比如:
insert into #tmp exec sp_who
要执行这一句,前提必须知道sp_who的结果集的表结构。
这样的语句又不能运行:select * into #tmp from exec sp_who解答:
1:
select * into #z from OPENROWSET(
'SQLOLEDB',
'SERVER=server;uid=sa;pwd=sapwd;Database=master','exec sp_who') as a2: 如果存储过程中用到临时表,要用set fmtonly off
select * into #z from OPENROWSET(
'SQLOLEDB',
'SERVER=server;uid=sa;pwd=sapwd;Database=master','SET FMTONLY OFF; exec 存储过程名') as a
-----------------------
或把结果集插入到临时表,然后再关联
解决方案 »
- 取相近值关联问题,请各位前辈帮忙,谢谢
- 求助:查询某个时间前后一定时间的数据的sql语句。
- 求生成一百條萬記錄的表(5 個答案以上結貼)
- 关于sql2000和2005的问题,高手请进。。。
- 邹老大,兄弟有点没太整明白,麻烦你结合个小例帮我讲讲
- SQL Server 2008找不到存储过程
- 有关自定义函数的问题
- 如何修改identity字段的初始值?
- 请教怎样将SQL Server 6.5中的某个数据库复制到SQL Server 7中?
- 请问大虾:能够在 SQL Server 2000里面为一张表建立定时触发器
- SQL2000从一个记录表取数插到一个固定列的表。
- 请教高手:这个SQLSERVER存储过程怎么设计效率高?
select * from #tmp
as
declare @count int,@stm nvarchar (100)
set @stm='select @cnt=count(*) from '+@table
exec sp_executesql @stm,N'@cnt int output',@cnt=@count output
return @count----使用传过来的参数
declare @a int
exec @a=tabl 'a'
select @a