Echo sql which has been run

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael McGarrigle

    Echo sql which has been run

    I am relatively new to SQL Server.

    I have a command file with the following contents :
    osql -E -i%1.sql -d%2 -oq:\%1.log

    The sql script file has a number of insert/update statements.
    The log file produced looks something like this :

    1> 2> (1 row affected)
    1> 2> (1 row affected)
    1> 2> (0 rows affected)

    Is there any setting which can be turned on such that the log file
    produced from this command file will echo the statement and then
    the number of rows which are affected.

    TIA.
  • Simon Hayes

    #2
    Re: Echo sql which has been run


    "Michael McGarrigle" <mjm@barwonwate r.vic.gov.au> wrote in message
    news:9d0cafdc.0 309111717.4dc8e faa@posting.goo gle.com...[color=blue]
    > I am relatively new to SQL Server.
    >
    > I have a command file with the following contents :
    > osql -E -i%1.sql -d%2 -oq:\%1.log
    >
    > The sql script file has a number of insert/update statements.
    > The log file produced looks something like this :
    >
    > 1> 2> (1 row affected)
    > 1> 2> (1 row affected)
    > 1> 2> (0 rows affected)
    >
    > Is there any setting which can be turned on such that the log file
    > produced from this command file will echo the statement and then
    > the number of rows which are affected.
    >
    > TIA.[/color]

    You can try adding -e -n to your command line. It works best if each
    statement is in its own batch:

    update...
    go
    insert...
    go

    Like that, you get each statement with the rowcount immediately after it. If
    all statements are in one batch, you'll get all the statements together then
    all the rowcounts together. That might be OK for you anyway, of course.

    Simon


    Comment

    Working...