Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    2

    Question Unanswered: Setting NOCOUNT ON outside a script

    Hi all,

    I have written a Java application which executes every T-SQL script file inside a folder using OSQL. I do not want the output file to contain the row count. Now I do not want to include "SET NOCOUNT ON" in each script. Is there a way to do this outside of the script?

    I tried passing it as a query along with the input file like this.

    Code:
    osql -n -S SERVERNAME -U USERNAME -P PASSWORD -Q "SET NOCOUNT ON" -i INPUTFILE.SQL -o OUTPUTFILE.LOG
    Now this does work, but it ends up hiding all error messages as well. So the log file remains empty at all times. How do I resolve this issue?

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    You need to use the -q parameter, instead of -Q. -Q is execute and exit.

  3. #3
    Join Date
    Sep 2011
    Posts
    2

    Thumbs up Solved!

    Quote Originally Posted by MCrowley View Post
    You need to use the -q parameter, instead of -Q. -Q is execute and exit.
    That did it! Thank you so much!

Tags for this Thread

Posting Permissions

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