如何在订单中执行多个查询

时间:2022-05-31 15:51:10

I have 26 queries to generate final output I want to automate the process and Execute all 26 queries one after another

我有26个查询来生成最终输出我希望自动化该过程并一个接一个地执行所有26个查询

how to execute all with a single click in the stepwise order

如何通过逐步顺序单击执行所有操作

3 个解决方案

#1


2  

This is a sample query only.

这只是一个示例查询。

CREATE PROCEDURE Your_Procedure_Name
AS 
BEGIN

    Write your First Query;

    Write your Second Query;

    Write your Third Query;

    .
    .
    .

    Write your Last Query;

END

And then execute the procedure using:

然后使用以下命令执行该过程:

EXEC Your_Procedure_Name;

It will execute your queries in the above order.

它将按上述顺序执行您的查询。

#2


1  

Schematic code follows:

示意图代码如下:

CREATE PROCEDURE ABC

AS

BEGIN

    <query 1> ;

    <query 2> ;

    <query 3> ;

    <query 4> ;

    <query 5> ;
    :
    :
END ;

Then:

然后:

EXEC ABC ;

Hope this helps.

希望这可以帮助。

#3


0  

You create a job in SQL Server Agent. You then have basically two options:

您在SQL Server代理中创建作业。然后你基本上有两个选择:

  • Put all the queries into a single script.
  • 将所有查询放入单个脚本中。
  • Put each query into a separate job step.
  • 将每个查询放入单独的作业步骤。

Or some combination of the two.

或两者的某种组合。

#1


2  

This is a sample query only.

这只是一个示例查询。

CREATE PROCEDURE Your_Procedure_Name
AS 
BEGIN

    Write your First Query;

    Write your Second Query;

    Write your Third Query;

    .
    .
    .

    Write your Last Query;

END

And then execute the procedure using:

然后使用以下命令执行该过程:

EXEC Your_Procedure_Name;

It will execute your queries in the above order.

它将按上述顺序执行您的查询。

#2


1  

Schematic code follows:

示意图代码如下:

CREATE PROCEDURE ABC

AS

BEGIN

    <query 1> ;

    <query 2> ;

    <query 3> ;

    <query 4> ;

    <query 5> ;
    :
    :
END ;

Then:

然后:

EXEC ABC ;

Hope this helps.

希望这可以帮助。

#3


0  

You create a job in SQL Server Agent. You then have basically two options:

您在SQL Server代理中创建作业。然后你基本上有两个选择:

  • Put all the queries into a single script.
  • 将所有查询放入单个脚本中。
  • Put each query into a separate job step.
  • 将每个查询放入单独的作业步骤。

Or some combination of the two.

或两者的某种组合。