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

  • Home
  • SEARCH
  • 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 7852245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:22:31+00:00 2026-06-02T19:22:31+00:00

I do some command line batch (.bat) with sqlcmd as this way: sqlcmd -i

  • 0

I do some command line batch (.bat) with sqlcmd as this way:

sqlcmd -i Scripts\STEP01.sql -o PROCESS.log -S MYSERVER -E -d MYDATABASE

and i need an output file (it’s works currently) and also the output trought the screen to do something like:

@echo off
echo The result of the query was:
    sqlcmd -i Scripts\STEP01.sql -o PROCESS.log -S MYSERVER -E -d MYDATABASE
pause
CHOICE /C:YN /M "Is the result accord?"
IF ERRORLEVEL 2 GOTO ENDWITHERROR
IF ERRORLEVEL 1 GOTO STEP2

Note:

  • Yes, the script works suscefull, it’s not an issue question.
  • And yes, I’ve a “print “something” on my sql. The log file gets the output.

Thanks a lot!

Similar question without answer:
How to run a sql script file using sqlcmd and output to both shell and file

  • 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-06-02T19:22:32+00:00Added an answer on June 2, 2026 at 7:22 pm

    I also couldn’t find a better way then @Sparky proposed. The following code adds his suggestion:

    @echo off
    
    :: this will execute the script into PROCESS.log
    sqlcmd -i Scripts\STEP01.sql -o PROCESS.log -S MYSERVER -E -d MYDATABASE
    
    :: this present the contents of PROCESS.log to the screen
    echo The result of the query was:
    type PROCESS.log
    
    pause
    CHOICE /C:YN /M "Is the result accord?"
    IF ERRORLEVEL 2 GOTO ENDWITHERROR
    IF ERRORLEVEL 1 GOTO STEP2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some command-line ruby scripts for things like pre-processing text files before uploading
Is there a simple way to log everything that appears on the command line
i want to create some command line utilities to manage many wordpress site, allowing
Is there some command line or AppleScript that I can write/run to make the
I have created a Java program which takes some command line arguments to run.
I'm writing a program in C++ and it takes some command line arguments. The
I have a Deplhi based Windows Service that, on installation, parses some command line
I'm writing a ruby program that executes some external command-line utilities. How could I
I have a command line executable that alters some bits in a file that
I'm writing some tests for a C++ command line Linux app. I'd like to

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.