Is there some way to stop the Changed database context to ... message when the piece of SQL has a USE database in it ?
Is there some way to stop the Changed database context to … message when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to set the errorlevel of
sqlcmd, which defaults to 0. Note: don’t confuse the errorlevel here with the exit code ofsqlcmdthat is returned to, say,cmd.exeas theERRORLEVEL.To disable this message for all of an
sqlcmdsession, use the-mcommandline option:To disable this message for a block of code, use the
:setvarbatch command:To use the
:setvar(or other SQLCMD batch commands) in Management Studio, you need to enable the SQLCMD mode for the query window you’re in (menu “Query / SQLCMD Mode”). You’ll see that it is enabled, when lines starting with ‘:’ have a gray background.