我有兩個存儲過程 - test_proc和calling_proc。過程calling_proc中正在調用過程test_proc。程序內調用程序操縱返回結果
結果是這樣的:
是可能只有一行從calling_proc(而不是四個行),這將是這樣的返回:
+-------+-------+-------+-------+
| test1 | test2 | test3 | test4 |
+-------+-------+-------+-------+
| 1 | 2 | 3 | 4 |
+-------+-------+-------+-------+
程序:
create procedure test_proc
as
begin
select 1 test1
select 2 test2
select 3 test3
end
create procedure calling_proc
as
begin
exec test_proc
select 4 test4
end
在第一PROC逗號將最後2種選擇。那麼你將不得不將exec test proc的結果存儲到一個臨時表中並在最終進程中加入它 – scsimon
你能舉個例子嗎?我不知道如何將存儲過程調用的結果存儲到臨時表中。 – FrenkyB
每個select語句都會給你一個結果集。所以如果你想在select語句中有多個列,用逗號分隔它們。這是非常基本的SQL。 https://docs.microsoft.com/en-us/sql/t-sql/queries/select-transact-sql –