Last active
August 29, 2015 14:23
-
-
Save kiyokura/d76c52e0ad27b409b01c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 誰かが作ったProcA | |
CREATE PROCEDURE usp_ProcA | |
@param int | |
AS | |
BEGIN | |
SET NOCOUNT ON | |
-- 実際はどっかのテーブルからデータ持ってくる | |
SELECT 1 AS hoge UNION SELECT 2 AS hoge | |
END | |
Go | |
-- 誰かが作ったProcB | |
CREATE PROCEDURE usp_ProcB | |
@param int | |
AS | |
BEGIN | |
CREATE TABLE #tmp( | |
hoge int | |
) | |
-- 実際はなんかいろいろ処理してる | |
INSERT INTO #tmp EXEC usp_ProcA 1 | |
SELECT * FROM #tmp | |
DROP TABLE #tmp | |
END | |
Go | |
-- これを作ってる | |
CREATE PROCEDURE usp_ProcC | |
@param int | |
AS | |
BEGIN | |
SET NOCOUNT ON | |
-- ここでProcBを実行してレコードとってきて、ProcCの中で使いたい | |
-- (ProcAとProcBのインタフェースは原則触れない…) | |
-- が、 | |
CREATE TABLE #tmp2( | |
hoge int | |
); | |
INSERT INTO #tmp2 EXEC usp_ProcB 1 | |
-- と書くと「An INSERT EXEC statement cannot be nested.」になる | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment