SQLCMD:- Informational Message – “Changed database context to ….”

Background

Let us quickly address a message pattern that is familiar to those who use sqlcmd.

Message

The message reads “Changed database context to ….”

Source

It is sourced to the presence of “use [database]” within a SQL command or file.

 

Remediation

We have a bit of control over whether SQL Server emits the message by adding the “-m” argument.

 

Argument

 

Value Meaning Sample
Changed database context to ‘tempdb’.
-m-1 Show all messages Msg 5701, Level 0, State 1, Server lab, Line 1
Changed database context to ‘tempdb’.
-m0 Show information messages Changed database context to ‘tempdb’.
-m1 Suppress messages with severity level less than 1 Nothing displayed

 

Crediting

Crediting StackOverflow.

Christian K.

Profile

https://stackoverflow.com/users/21567/christian-k

Link

Started out like over 25 years ago with C, C++ and then some Java, as well as all sorts of scripting languages on UNIX systems. A whole boat load of CORBA and other stuff around distributed computing. Since the last decade, doing .NET-based development on Windows. Mostly managed, but sometimes native stuff as well.

 

 

References

  1. StackOverflow
    • How to stop the “Changed database context to …” message
      Link
  2. Microsoft
    • SQLCMD
      • SQLCMD Utility
        Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s