Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Execute Multiple Queries in a order

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

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

like image 749
Urstruely Ananth Avatar asked Nov 24 '25 09:11

Urstruely Ananth


2 Answers

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.

like image 120
DineshDB Avatar answered Nov 27 '25 00:11

DineshDB


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.

like image 30
FDavidov Avatar answered Nov 26 '25 23:11

FDavidov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!