Results 1 to 9 of 9

Thread: Script to run sql scritp files ?

  1. #1
    Ben Guest

    Script to run sql scritp files ?

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  2. #2
    Jun Guest

    Script to run sql scritp files ? (reply)

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun








    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  3. #3
    Ben Guest

    Script to run sql scritp files ? (reply)

    Hello Jun,

    Thank u for your reply.

    But what I'm trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These're the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u've any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun








    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  4. #4
    alterx Guest

    Script to run sql scritp files ? (reply)


    Even I am facing a similar issue. The closest I could get in resolving this is: In your batch file put the following stmt:

    isqlw -S Myserver -d pubs -U demo -P demo -f "c:Createcust.sql" "c:CreateOrder.sql"

    What the above does is invokes the query analyzer and loads it with these 2 files.

    The problem that is still not resolved is that it does not run the scripts automatically, you have to press the F5 button for it to execute.

    Does anyone knows how it can automatically execute it??


    ------------
    Ben at 5/12/2002 5:24:24 AM

    Hello Jun,

    Thank u for your reply.

    But what I'm trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These're the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u've any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun








    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  5. #5
    Carl Guest

    Script to run sql scritp files ? (reply)




    ------------
    alterx at 5/15/2002 5:03:50 PM


    Even I am facing a similar issue. The closest I could get in resolving this is: In your batch file put the following stmt:

    isqlw -S Myserver -d pubs -U demo -P demo -f "c:Createcust.sql" "c:CreateOrder.sql"

    What the above does is invokes the query analyzer and loads it with these 2 files.

    The problem that is still not resolved is that it does not run the scripts automatically, you have to press the F5 button for it to execute.

    Does anyone knows how it can automatically execute it??


    ------------
    Ben at 5/12/2002 5:24:24 AM

    Hello Jun,

    Thank u for your reply.

    But what I'm trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These're the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u've any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun






    Are you familiar with scheduled jobs, it should do the trick.

    Go Management/Jobs/New Job

    In the Steps tab create a new step. Make the type TransactSQL and paste your script into the Command box.

    Then, schedule it for whatever period you like.

    Carl



    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  6. #6
    Guest

    Script to run sql scritp files ? (reply)

    Are you familiar with scheduled jobs, it should do the trick.

    Go Management/Jobs/New Job

    In the Steps tab create a new step. Make the type TransactSQL and paste your script into the Command box.

    Then, schedule it for whatever period you like.

    Carl





    ------------
    Carl at 5/15/2002 5:15:59 PM




    ------------
    alterx at 5/15/2002 5:03:50 PM


    Even I am facing a similar issue. The closest I could get in resolving this is: In your batch file put the following stmt:

    isqlw -S Myserver -d pubs -U demo -P demo -f "c:Createcust.sql" "c:CreateOrder.sql"

    What the above does is invokes the query analyzer and loads it with these 2 files.

    The problem that is still not resolved is that it does not run the scripts automatically, you have to press the F5 button for it to execute.

    Does anyone knows how it can automatically execute it??


    ------------
    Ben at 5/12/2002 5:24:24 AM

    Hello Jun,

    Thank u for your reply.

    But what I'm trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These're the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u've any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun







    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  7. #7
    Guest

    Script to run sql scritp files ? (reply)

    That is not the point. The objective is to provide users a batch file, which they can run whenever. Once the batch file is run all the called scripts should be executed .



    ------------
    at 5/15/2002 5:23:24 PM

    Are you familiar with scheduled jobs, it should do the trick.

    Go Management/Jobs/New Job

    In the Steps tab create a new step. Make the type TransactSQL and paste your script into the Command box.

    Then, schedule it for whatever period you like.

    Carl





    ------------
    Carl at 5/15/2002 5:15:59 PM




    ------------
    alterx at 5/15/2002 5:03:50 PM


    Even I am facing a similar issue. The closest I could get in resolving this is: In your batch file put the following stmt:

    isqlw -S Myserver -d pubs -U demo -P demo -f "c:Createcust.sql" "c:CreateOrder.sql"

    What the above does is invokes the query analyzer and loads it with these 2 files.

    The problem that is still not resolved is that it does not run the scripts automatically, you have to press the F5 button for it to execute.

    Does anyone knows how it can automatically execute it??


    ------------
    Ben at 5/12/2002 5:24:24 AM

    Hello Jun,

    Thank u for your reply.

    But what I'm trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These're the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u've any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun







    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  8. #8
    Guest

    Script to run sql scritp files ? (reply)

    Have fun with your batch file solution!

    Who uses batch files anyhow...time has marched on!


    ------------
    at 5/15/2002 5:30:30 PM

    That is not the point. The objective is to provide users a batch file, which they can run whenever. Once the batch file is run all the called scripts should be executed .



    ------------
    at 5/15/2002 5:23:24 PM

    Are you familiar with scheduled jobs, it should do the trick.

    Go Management/Jobs/New Job

    In the Steps tab create a new step. Make the type TransactSQL and paste your script into the Command box.

    Then, schedule it for whatever period you like.

    Carl





    ------------
    Carl at 5/15/2002 5:15:59 PM




    ------------
    alterx at 5/15/2002 5:03:50 PM


    Even I am facing a similar issue. The closest I could get in resolving this is: In your batch file put the following stmt:

    isqlw -S Myserver -d pubs -U demo -P demo -f "c:Createcust.sql" "c:CreateOrder.sql"

    What the above does is invokes the query analyzer and loads it with these 2 files.

    The problem that is still not resolved is that it does not run the scripts automatically, you have to press the F5 button for it to execute.

    Does anyone knows how it can automatically execute it??


    ------------
    Ben at 5/12/2002 5:24:24 AM

    Hello Jun,

    Thank u for your reply.

    But what I'm trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These're the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u've any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT 'Running the first Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT 'Running the second Stored Procedure' -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT 'Running the third Stored Procedure' -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The 'Print' statement is used just you to easily to look at the error message since the Message "Running the x Stored Procedure" is always printed before that SP started to run.
    *******/

    Hope that's what you want to do!

    Jun







    ------------
    Ben at 5/11/2002 12:19:16 AM

    I've list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

  9. #9
    Ben Guest

    Script to run sql scritp files - Got it :)

    Hello alterx,

    Here is it:

    osql -S YourDatabaseServer -U YourUserID -P YourPassword <YourScriptToRun.sql

    Ben

    ------------
    alterx at 5/15/2002 5:03:50 PM


    Even I am facing a similar issue. The closest I could get in resolving this is: In your batch file put the following stmt:

    isqlw -S Myserver -d pubs -U demo -P demo -f &#34;c:Createcust.sql&#34; &#34;c:CreateOrder.sql&#34;

    What the above does is invokes the query analyzer and loads it with these 2 files.

    The problem that is still not resolved is that it does not run the scripts automatically, you have to press the F5 button for it to execute.

    Does anyone knows how it can automatically execute it??


    ------------
    Ben at 5/12/2002 5:24:24 AM

    Hello Jun,

    Thank u for your reply.

    But what I&#39;m trying to do is somthing like this :

    run script1.sql
    run script2.sql
    run script3.sql
    ...
    run scriptn.sql

    These&#39;re the script files used to create the Stored Procedures. I was thinking of running them in a batch file, instead of running them one-by-one.
    Do u&#39;ve any idea?

    Thanks again,
    Ben


    ------------
    Jun at 5/11/2002 7:28:20 AM

    Hi Ben!

    You create a Stored Procedure to run as many Stored Procedure as you want. A sample code would look like:

    CREATE PROC Run_All_Your_SP

    AS

    PRINT &#39;Running the first Stored Procedure&#39; -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.

    PRINT &#39;Running the second Stored Procedure&#39; -- Just Print a message
    EXEC Your_SP2 -- If you need to provide parameter, do it here.

    PRINT &#39;Running the third Stored Procedure&#39; -- Just Print a message
    EXEC Your_SP1 -- If you need to provide parameter, do it here.
    ......

    EXEC Your_SP1000
    GO

    /*****
    The &#39;Print&#39; statement is used just you to easily to look at the error message since the Message &#34;Running the x Stored Procedure&#34; is always printed before that SP started to run.
    *******/

    Hope that&#39;s what you want to do!

    Jun








    ------------
    Ben at 5/11/2002 12:19:16 AM

    I&#39;ve list of sql script files that is run one-by-one from the Query Analyzer to create custom Stored Procedures. It becomes tedious when the no. of script files grow.

    Is there a way to write a script to include all the sql script files to be run?

    Thanks in advance,
    Ben

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •