Job step does not specify database yet job completes successfully -- which db runs against?

I have inherited a database and jobs that go with it.  One of the jobs has a step that executes a proc but does not specify which database to find the proc in.  There are actually 2 different databases on this server that have procedures with the name listed in the job step.  The job runds successfully.  Does it execute this proc in every db that has a proc by that name?  If not then which db does it execute against?

See attached screenshot of the job step.


Eric Doc1.doc
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
Look in the history for the job.  You should  be able to determine from that which db it ran against, then change the job to reflect the desired db (that one or other one).

I've had this issue too, don't know yet what internal glitch in SQL Server causes it.
Eric3141Author Commented:
View History for the job tells me the server name and job name and step name but I don't see the name of the db.
Scott PletcherSenior DBACommented:
Ouch, you're right, sorry, thought the step history had the db name.

See if the database_name column in msdb.dbo.sysjobstep is actually NULL or empty for that job:

SELECT database_name, *
FROM msdb.dbo.sysjobsteps
WHERE job_id = (SELECT job_id FROM msdb.dbo.sysjobs WHERE name = '<job_name_goes_here>')

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eric3141Author Commented:
Worked great.  There are 2 databases on this server each with a proc by that name.  I thought maybe both of them got executed.  However, the results of the query you gave me show that only one of the procs is being executed.  The query gave me the db name.

I'll change the job now to explicity designate the db by name.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.