Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Cross Database Query Permissions Expand / Collapse
Author
Message
Posted Tuesday, January 21, 2014 8:40 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 12:07 PM
Points: 2,766, Visits: 7,241
I have multiple databases on the same server, let's call them Sales, Vehicle and Cheese.
In the databases are tables that I would like to call from the other databases. For example, Sales.dbo.Money, Vehicle.dbo.Wheels and Cheese.dbo.Delicious.

When I am in Sales and I try to run the query
SELECT * FROM Cheese.dbo.Delicious

I get
Msg 208, Level 16, State 1, Line 1
Invalid object name Cheese.dbo.Delicious

However, if I am in Cheese and I try to run the query
SELECT * FROM Sales.dbo.Money

I get the proper results of the query.

I cannot access any data in Cheese from other databases with a three part table name. I can access anything in Sales or Vehicle from any of the databases using a three part table name specification, including from Cheese.

I think I have a permissions problem, but I'm not sure where it is. My account is on the server, but not on any of the individual databases. Where should I be looking?

When I'm using a cross database query, it is using my permissions for both databases or some other specification.

If I set up a synonym in the Sales database for the table reference, for example
CREATE SYNONYM TastyCheese FOR Cheese.dbo.delicious

Is a different set of permissions needed? Is there a specific account that synonyms use?

I've never seen this error come up before for a simple same server, cross database query.


--------------------------------------
When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
--------------------------------------
It’s unpleasantly like being drunk.
What’s so unpleasant about being drunk?
You ask a glass of water. -- Douglas Adams
Post #1533143
Posted Tuesday, January 21, 2014 9:00 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 10:20 AM
Points: 261, Visits: 469
It is most likely that your login is not defined as a user in the Cheese database, or a member of a group that is defined as a user in the Cheese database. Can you run the following?
use Cheese

If not, then you are definitely not defined in the Cheese database.

To simplify permissions (and referential integrity, and recovery), have you considered moving the tables from the Cheese database into a central database as a schema, rather than as a standalone database?
Post #1533184
Posted Tuesday, January 21, 2014 9:06 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 12:07 PM
Points: 2,766, Visits: 7,241
Matt Crowley (1/21/2014)
It is most likely that your login is not defined as a user in the Cheese database, or a member of a group that is defined as a user in the Cheese database. Can you run the following?
use Cheese

If not, then you are definitely not defined in the Cheese database.

To simplify permissions (and referential integrity, and recovery), have you considered moving the tables from the Cheese database into a central database as a schema, rather than as a standalone database?


Got it, as it frequently is, the problem turned out to be a simple typo.

Thanks for the assistance!


--------------------------------------
When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
--------------------------------------
It’s unpleasantly like being drunk.
What’s so unpleasant about being drunk?
You ask a glass of water. -- Douglas Adams
Post #1533194
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse