Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to supress 'Changed database context to ... '?

Author  Topic 

CMawby
Starting Member

1 Post

Posted - 2007-11-04 : 19:24:03
This is a small thing that has been annoying me for some time, so I thought I would finally get around to asking and see if there is a known solution ...

In my T-SQL scripts (executed via SQLCMD) whenever a USE statement is executed -- there is a corresponding 'Changed database context to <dbname>' output statement. In most of my scripts there are quite a few changes as it is necessary to build multiple db's ... resulting in rather a lot of output 'Changed database context to ...' statements.

Can someone suggest a way to suppress these output statements (note, I need to use sqlcmd scripts, sop switching is not an option )? This is more an annoyance than a functional need ... so any input appreciated :-).

thx,
C

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-11-04 : 22:28:02
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:\>



elsasoft.org
Go to Top of Page
   

- Advertisement -