在另一个存储中调用存储过程

在另一个存储中调用存储过程

本文介绍了在另一个存储中调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有两个具有相同输入的存储过程,该输入包含(datefrom,dateto和accountId).第一个存储过程根据从from到到之间的日期返回数据,第二个存储过程根据在datefrom之前的日期返回数据.
现在,我要输入所有这些输入,并调用存储在第一个存储过程中的第二个存储.任何人都可以在这方面帮助我.拜托???
谢谢alot

Hi all,
I have two stored procedures that have the same input, the input contains (datefrom,dateto and accountId). The first stored procedure returns data according to date between from and to and the second stored procedure returns the data according to before the datefrom.
I want now to enter all these inputs and call the stored second stored in the first stored procedure. can any body help me in that. Please????
thanks alot

推荐答案



-- create temporary table to store the result
IF OBJECT_ID('tempdb..#result')
   DROP TABLE #result
CREATE TABLE #result
   (
   datefrom  DATETIME NULL,
   dateto    DATETIME NULL,
   accountId INT      NULL
   )

-- insert from first proc
-- NOTE columns must in the same order as the proc result
INSERT INTO #result
   (
   datefrom,
   dateto,
   accountId
   )
EXEC firstProcedure @param1,@param2 -- replace with your procedure name and parameters

-- insert from second proc
-- NOTE columns must in the same order as the proc result
INSERT INTO #result
   (
   datefrom,
   dateto,
   accountId
   )
EXEC secondProcedure @param1,@param2 -- replace with your procedure name and parameters

-- final result
SELECT  *
FROM    #result


这篇关于在另一个存储中调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:18