Re: SQLCMD "-r" option (SQL 2K5)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Oops, I meant I was testing with -m, not -V; although I'll probably test
with both :)

Thanks

"Erland Sommarskog" <esquel@xxxxxxxxxxxxx> wrote in message
news:Xns97D517E72650Yazorman@xxxxxxxxxxxx
Mike C# (xxx@xxxxxxx) writes:
OK, so I'm playing with SQLCMD and trying to get the "-r" option to
work. According to BOL it's supposed to redirect error messages of
severity level 17 or higher to the screen (stderr). Presumably this
would be useful in situations where you're running a script with the
"-o" option, so that output would be sent to a file and error messages
would be sent to the screen and not included in the output file. When I
run it in the following:

sqlcmd -S SQL2005 -Q"raiserror('Error in text', 17, 1)" -r 0 -o test.txt

or

sqlcmd -S SQL2005 -Q"raiserror('Error in text', 17, 1)" -r 1 -o test.txt

The error message is sent to the output file (test.txt) and not to the
screen. Is there another option that needs to be set, or am I reading
the
documentation wrong?

The documenation does not appear to be very clear. And it's flat wrong
on one point.

If you specify the output file with -o, -r has no effect. However, if you
use > for the output file, -r works as advertised. Almost. The cutoff
level
is 11, not 17.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx


.



Relevant Pages

  • Re: SQLCMD "-r" option (SQL 2K5)
    ... severity level 17 or higher to the screen. ... so that output would be sent to a file and error messages ... The error message is sent to the output file and not to the ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.tools)
  • Re: Deleting all data
    ... Copy and paste the result into a query window, and the run it over and ... until there are no error messages. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: T-SQL Debugger Doesnt Allow Stepping Through Stored Procedures no other procedure with the s
    ... There is no error messages also, ... the debugger to work. ... SQL Server does not have privilege to write to your machine from ... In Books Online, you can look under Troubleshooting->SQL Server Tools ...
    (comp.databases.ms-sqlserver)
  • Re: dbcc shrinkdatabase
    ... I don't see any error messages but its obvious that the command never ... When I run the command on other databases it runs fine with all the ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: SQL Server 2005: Error 14258...SQL Server Agent is starting
    ... I don't know what happens to yesterdays post, put here is the output file ... cannot perform this operation while SQL Server Agent is ... If you try stopping the SQL Server Service or the Agent service from ... After checking TechNet I did notice the question from Vsiat which ...
    (microsoft.public.sqlserver.tools)