如何在临时表中获取存储过程结果 [英] how to get stored procedure result in temporary table
本文介绍了如何在临时表中获取存储过程结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个存储过程,该过程返回一个表作为输出.
我想在临时表中获取此输出.
i have a stored procedure which return a table as ouput.
I want to get this ouput in a temporary table.
推荐答案
只需使用临时表并将其插入.
注意:如果要通过多个事务共享数据,请使用全局临时表或其他常规临时表(全局临时表以##符号开头).
在这里,我使用了普通的临时表.
例如,
Just use temporary table and insert it.
Note:If you want to share the data over multiple transaction then use global temporary table or else use normal temporary table(Global temporary table have start with ## symbol).
Here I used normal temporary table.
For example,
--drop table if the table already exists
IF OBJECT_ID('tempdb..#tempTbl') IS NOT NULL
drop table #TempTbl
select col1,col2 into #TempTbl from Table1
select * from #TempTbl
您好,
如果您是程序,请给出id,name,sal列,例如
exec sp_data(存储过程)
结果
ID NAME SAL
1 A 500
2 B 300
Hi,
If you are procedure give the id,name,sal columns as out put like
exec sp_data(stored procedure)
Result
ID NAME SAL
1 A 500
2 B 300
create table #temp1(ID int,NAME varchar(89),SAL money)
INSERT #TEMP(ID,NAME,SAL)
EXEC SP_DATA
^ ]
这篇关于如何在临时表中获取存储过程结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文