osql command

  • I have this command running in sql server agent.

    osql /U a /S A\B -d AB /P 1 /Q "exec test" /o \\C1122$\D$\test.rpt -w 500

    If I want to output the query result in multiple locations, how can I do it using osql.

  • You need to run it multiple times or if the output is the same, just copy the file.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I tried this:

    osql /U a /S A\B -d AB /P 1 /Q "exec test" /o \\C1122$\D$\test.rpt -w 500

    osql /U a /S A\B -d AB /P 1 /Q "exec test" /o \\C2122$\D$\test.rpt -w 500

    But, it writes to only the first location \\C1122$\D$\test.rpt and Not to \\C2122$\D$\test.rpt

  • Do you get an error?

    Do you run them one by one? Are they in a batch file?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I am running it from sql agent job, it doesn't give any error.

    I am trying to run both commands in single step in a job

  • Create a step for each command or create a batch file to run both.

    If you send both in a single command, it will ignore the second and all the others.

    Wild question: Why are you using osql instead of bcp? You're missing a lot of functionality.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply