Reputation: 7377
I have 2 schemas database1@server
and database2@server
.
I want to know how to grant priveleges for database2 to read from database1.
example executing in database2:
select * from database1..table1
Upvotes: 0
Views: 241
Reputation: 6661
You will have to make sure the user in database2
is added to database1
(sp_adduser
or sp_addalias).
You can find your current user by doing select user_name()
and get a list of users within a database by executing sp_helpuser
in that database.
Assuming we have db_user1 and dbuser2, we would add the alias like this:
use database1
go
sp_addalias db_user2, dbuser1
go
From that point forward, when db_user2 is accessing database1, it will be with db_user1's credentials, rights and privileges.
If you add the user, instead of adding the alias, then you will have to grant privileges for tables in the schema to the user (or group that the user is a member of).
Upvotes: 1