Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL Job Fails Because of Invalid Object Name

$
0
0

Why would a SQL Job in SQL Server 2008 R2 complain about an object not being valid when the job is not “instructed” to access (or use) that particular object?

My SQL Server hosts a database called dbsVendors. In dbsVendors, I have a stored procedure, spValidate_Emails, plus a SQL Job called jobUpdateEmails that will execute the stored procedure. At one time, the same SQL instance use to host a database called dbsAudits that had a table called tblAudits. There were no plans to continue using dbsAudits and this database had not been used in over a year, so it was dropped 3 or 4 weeks ago. Since then, the jobUpdateEmails has been throwing the following error:

            Date: 3/18/2014 3:50:00 AM

              Log: Job History (jobUpdateEmails)

         Step ID: 1

          Server: FooSQL\Fobar

         Job Name: jobUpdateEmails

       Step Name: Validate_Email_Addresses

        Duration: 01:02:00

    Sql Severity: 16

   Sql Message ID: 208

 Operator Emailed:

Operator Net sent:

   Operator Paged:

Retries Attempted: 0

         Message: Executed as user: NT AUTHORITY\NETWORK SERVICE.

                  Invalid object name 'dbsAudits.dbo.tblAudits'.

                  [SQLSTATE 42S02] (Error 208).

                  The step failed.

 The error message mentions that the SQL Job references the old database, even though the job contains no references to dbsAudits. The job has a single step which is:

     EXEC spValidate_Emails

 This is a stored procedure that contains:

 ALTERPROCEDURE [dbo].[spValidate_Emails]

AS

UPDATEdbsVendors.dbo.tblSuppliers

  SET [Status]= 'Current'

 WHEREEmail IN(SELECT Email FROM dbsVendors.dbo.tblEmails)

DELETE FROMdbsVendors.dbo.tblEmails

 WHEREEmail IN(SELECT EmailAddressFROM dbsVendors.dbo.tblOldContacts)

As you can see, there is no reference to dbsAudits.dbo.tblAudits in the above procedure. So I don’t understand why the job would throw the above error.

Thank you, Steven


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>