Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3280234
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:40:54+00:00 2026-05-17T19:40:54+00:00

I am sure these has been asked before but cannot find clear instruction how

  • 0

I am sure these has been asked before but cannot find clear instruction how to create a
batch file lets call it “Update Database” this batch file should

Execute sql scripts located in different folders
Execute another 3 bat files.

Any quick examples how to do it?Never done it before
thanks a lot

EDITED

Can I do this?

:On Error exit 

:r C:\myPath\MasterUpdateDatabase.bat
GO 
SQLCMD -S (Local) -i C:\myPath\InsertUsername.sql

I get an error:

“GO” is not recognized as internal external command

Thanks for any input

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:40:54+00:00Added an answer on May 17, 2026 at 7:40 pm

    It looks like you’re trying to use DOS commands to create a batch file that either (a) executes other batch files or (b) executes SQLCMD to run sql or a sql script.

    Here are a couple examples all rolled into one. I’m using the DOS command START with the /WAIT switch, which will keep your original “master” batch file running in one window and execute the subsequent file or commands in a new window. That new window stays open until the script finished AND exits.

    Some of the ECHOs probably aren’t required, but the script will talk back to you for now, a little.

    @echo off
    

    So, this is pretty simple in the sense that you’re just running the script. If you’re script1.bat has break points, you can return an error back to the main script and have it end immediately. I wasn’t clear if that was what you needed the master script to do.

    echo Starting Database Update.
    echo.
    
    echo Excuting Script 1
    echo.
    start /wait C:\path\to\your\script1.bat
    
    echo If there was a problem, break here.
    Pause
    
    echo Excuting Script 2
    echo.
    start /wait C:\path\to\your\script2.bat
    
    echo If there was a problem, break here.
    Pause
    

    Here is where did used the same START /WAIT to run SQLCMD, which in this case just returns results from the query. One thing to note here is that the -Q (uppercase) runs the query and quits. If you use -q (lowercase) it will run the query and sit open in SQLCMD waiting for another query.

    echo.
    echo Running SQLCMD: "select top 100 * from sys.objects"
    start /wait sqlcmd -S (local) -Q "select top 100 * from sys.objects"
    

    And this is how you can run a sql script, which is what the -i denotes, but I also didn’t run this in the START /WAIT as earlier. Not that you have to, but I wanted to show both examples. What this also shows is the -b will end the batch process if your script returns an error, which is useful if you’re running multiple scripts that depend on success of the former(s).

    echo.
    echo Running SQLCMD from an (-i)nput file:
    sqlcmd -S (local) -i  C:\path\to\your\script.sql -b
    
    echo.
    echo Update Complete.
    pause
    
    End
    

    So, I assumed you were looking for a .bat or .cmd file that utilized SQLCMD. The example I provided is pretty basic, but hopefully it sets you on the right path.

    OH! And remember that CTRL+C breaks a batch script in process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sure this has been asked before, but I cannot find it. Basically,
I am sure this problem has been asked before but I cannot seem to
Well, I'm sure this question has been asked before but I'm yet to find
I'm sure this has been asked before, but I searched and couldn't find an
I'm sure this question has been asked before, but I'm too frustrated to find
I'm quite sure this has been asked before but I can't for the life
I am sure this has been asked before but my google-fu was not able
I'm pretty sure this has been asked before, but I can't for the life
I am not sure whether this has been asked before; I did a few
Halo I'm sure this question has been asked many times in the past, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.