我有两个存储过程 - 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 –