Changed database context to 'xxxx'.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • franciscojmora
    New Member
    • Aug 2010
    • 6

    Changed database context to 'xxxx'.

    I need to get rid of this message on my report:Changed database context to 'xxxx'.

    Thank you!
  • Jerry Winston
    Recognized Expert New Member
    • Jun 2008
    • 145

    #2
    Update your adult content filters.

    No, that was an attempt at humor.

    Seriously, though, we will need to know a lot more about what you are trying to do and what you have done so far before we can possibly be of any assistance.

    What data source?
    What report?
    What software?
    What versions?
    What OS/Servers?

    Comment

    • franciscojmora
      New Member
      • Aug 2010
      • 6

      #3
      Jerry: Thank you again, here is some of the facts being used: I just execute a simple query and then I use "EXEC msdb.dbo.sp_sen d_dbmail" to email it some of my co-workers as an EXCEL file.

      Comment

      • Alex Papadimoulis
        Recognized Expert New Member
        • Jul 2010
        • 26

        #4
        From which system are you executing this query from? For example... are you just using like SQL Query Management Studio? Or, do you have a web application connecting to SQL?

        Comment

        • franciscojmora
          New Member
          • Aug 2010
          • 6

          #5
          Alex:

          I am executing this SQL script as a JOB from within the SQL Management Studio and works great except that the first row in my Excel file has the line that says "Changed database context to 'xxxx'."

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            In my experience this error usually means a timeout or memory overload.
            At some point in the query there is too much data.

            Comment

            • Jerry Winston
              Recognized Expert New Member
              • Jun 2008
              • 145

              #7
              Is the:
              Code:
              USE [myDbName]
              line absolutely necessary? If you can run your processes from on database, you can eliminate this message by not switching database context. You can start your TSQL job step script in the context of source database.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32668

                #8
                Which network account is the SQL Server Agent configured to use?
                Is this account set up with the ability to email (A default account of System would not be for instance)?

                Comment

                • franciscojmora
                  New Member
                  • Aug 2010
                  • 6

                  #9
                  The solution to my problem,was quite simple; Everytime I used SP_Send_dbmail with a file attachment, the first line on my output was "Changed database context to 'XXXXX'. I found that when using SP_SEND_DBMAIL, I just needed to use the parameter "@execute_query _database=XXXXX "; This simple entry, eliminated that annoying output line!!!

                  Thanks for all your help!

                  Comment

                  • Jerry Winston
                    Recognized Expert New Member
                    • Jun 2008
                    • 145

                    #10
                    Thanks for coming back and posting the solution!

                    Comment

                    Working...