从 1 个 SQL 文件运行多个查询,显示多个表中的结果 [英] Run multiple queries from 1 SQL file showing result in multiple tables
问题描述
我有一组用于回归测试的查询.这些基本上是存储在不同文件中的选择语句.
I have a set of queries for regression testing. These are basically select statements stored in different files.
File Query
A SELECT a ...
B SELECT b ...
C SELECT c ...
这意味着我必须打开多个文件并运行查询.是否可以将这些 SELECT 语句放在同一个文件中,但在不同的表和/或不同的结果集中显示结果?
This means that I have to open up multiple files and run the queries. Is it possible to put these SELECT statements in the same file but show the results in different tables and/or in different result sets?
我想要一个文件 D,显示不同表中 SELECT 语句 a、b 和 c 的结果.(最好只包含文件 A、B、C,但我当然可以复制粘贴它).这可能吗?如果可能,那么我该怎么做?
I want to have a file D showing the result from the SELECT statements a,b and c in different tables. (It would be preferable just to include the files A,B,C but I can of course copy paste it). Is this possible? In case it is possible then how do I do it?
推荐答案
如果您想要多个响应,您可以创建一个存储过程.
If you want multiple responses you can create a stored procedure.
使用存储过程,您可以进行一次调用并返回多个数据集:
With a stored procedure, you can make one call and it return multiple data sets:
CREATE PROCEDURE Foo
AS
SELECT * AS Table1
SELECT * AS Table2;
SELECT * AS Table3;
GO
EXECUTE Foo;
这篇关于从 1 个 SQL 文件运行多个查询,显示多个表中的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!