Thursday, June 07, 2007 9:10 PMIs there a way to suppress the "Changed Database Context to " messages in SQLCMD?
For example, I get the following:
1> use master
Changed database context to 'master'.
I am trying to migrate some legacy batch files that called isql and used the output files. These extra "Changed Database Context to " messages are causing our scripts to break, and I was hoping to avoid having to write something extra to handle these messages.
Saturday, June 09, 2007 12:47 AM
you can wipe it all out with the management studio or enterprise manager
find and replace feature. make use of the wildcard
1. open management studio
2. click on new query
3. type this sample query
4. click on edit /find and replace/quick replace
5. in the find what type use *
6. in the replace with: dont type anything
7. expand find option.
8. check use option and the chose wildcard
9. click replace all
here's some reference using microsft search feature with wildcards s
Sunday, June 10, 2007 6:02 PM
Are you using sqlcmd to execute these now? I don't think that warning message is displayed by default - I think that warning has a error severity level of 10. Are you changing the error level in the script? Are you trying to capture informational messages?
You can set the SQLCMDERRORLEVEL variable or start sqlcmd using the -m switch to set the error level and control what severity level of errors generate the messages.
- Proposed As Answer by Naomi NMicrosoft Community Contributor Thursday, August 26, 2010 8:25 PM
- Marked As Answer by Kalman TothMicrosoft Community Contributor, Editor Wednesday, September 01, 2010 8:58 PM
Monday, June 11, 2007 1:39 PMModerator
True, sqlcmd prints any informational message that are sent by the server. In the following example, after the Transact-SQL statements are executed, an informational message is printed.
Thursday, August 26, 2010 8:25 PM
check SQLCMDERRORLEVEL and the -m flag passed to sqlcmd.
C:\>sqlcmd -Q "use master" -E Changed database context to 'master'. C:\>sqlcmd -Q "use master" -E -m 1 C:\>
Premature optimization is the root of all evil in programming. (c) by Donald Knuth
Naomi Nosonovsky, Sr. Programmer-Analyst