Eric Labashosky
Eric Labashosky

Reputation: 29971

What causes error 4063 - Database ...databasename... has not been opened yet

I have an scheduled agent that is trying to access a database on another server. When it runs I get an error 4063 - Database ...databasename... has not been opened yet.

The servers is listed in the ACL as manager.

What are some other possible causes for this errors?

Upvotes: 1

Views: 8577

Answers (4)

Andrew Magerman
Andrew Magerman

Reputation: 1413

One tip: print out beforehand db.Server and db.Filepath to see what exactly you are trying to open.

Upvotes: 0

Jozsef Lehocz
Jozsef Lehocz

Reputation: 340

Check the server document of the server, where the database resides. In the Access server section does the Trusted servers field contains the name of the server, where the agent runs?

Upvotes: 0

Kerr
Kerr

Reputation: 2812

It's possible to get a handle to a database without opening it. If you try and call most methods without opening it first then you will get that error. The most likely explanation though is that you don't have access to open it.

What id signed the agent? Probably not the server. The agent will run with the authority of the agent signer, so that is the id that needs to be in the ACL of the database you are trying to open.

There are a whole bunch of rules about how agents can run under different authorities and on behalf of different users. That can get pretty complex if the situation requires it. But check the agent signer has rights to open the database first then look at any "run on behalf of" settings.

Upvotes: 0

Anders Lindahl
Anders Lindahl

Reputation: 42870

Does the other server trust the server executing the agent? Check the server document -> Security -> Trusted servers.

Upvotes: 2

Related Questions