SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need Help with Views


Need Help with Views

Author
Message
Thom A
Thom A
SSC Guru
SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)

Group: General Forum Members
Points: 92162 Visits: 23166
Eirikur Eiriksson - Monday, February 4, 2019 7:41 AM

The user/group will have a select permission on the source table, does not matter if they connect to database A or database B, they can only select from the table and in the source database, they can only see that table. Unless one starts to implement a stored procedure to encapsulate (execute as) the object, this is the most straight forward method.
Cool

As there is no need for using a four part identifier, this solution "contains" things Wink

Not gunna lie, you lost me there Eirikur. Hehe Perhaps some T-SQL will speak "louder" than words; could you show an example please?



Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
sql2k8
sql2k8
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3115 Visits: 1239
Eirikur Eiriksson - Sunday, February 3, 2019 6:04 AM
Thom A - Saturday, February 2, 2019 7:54 AM
Eirikur Eiriksson - Saturday, February 2, 2019 6:57 AM

Suggest you look into using a synonym for this.
Cool

How is that going to help with the permissions here Eirikur?

Create a schema and synonym in the destination database for the target table and grant select to the user/group on both the synonym and the target table, makes it transparent and the user/group can only do select.
Cool

I created schema and synonym in the destination database B
Eirikur Eiriksson - Sunday, February 3, 2019 6:04 AM
Thom A - Saturday, February 2, 2019 7:54 AM
Eirikur Eiriksson - Saturday, February 2, 2019 6:57 AM

Suggest you look into using a synonym for this.
Cool

How is that going to help with the permissions here Eirikur?

Create a schema and synonym in the destination database for the target table and grant select to the user/group on both the synonym and the target table, makes it transparent and the user/group can only do select.
Cool

I created a schema C and TestSynonym in the destination database B. I had created views in database B referring to the schema
Eirikur Eiriksson - Sunday, February 3, 2019 6:04 AM
Thom A - Saturday, February 2, 2019 7:54 AM
Eirikur Eiriksson - Saturday, February 2, 2019 6:57 AM

Suggest you look into using a synonym for this.
Cool

How is that going to help with the permissions here Eirikur?

Create a schema and synonym in the destination database for the target table and grant select to the user/group on both the synonym and the target table, makes it transparent and the user/group can only do select.
Cool

Eirikur Eiriksson - Sunday, February 3, 2019 6:04 AM
Thom A - Saturday, February 2, 2019 7:54 AM
[quote]
Eirikur Eiriksson - Saturday, February 2, 2019 6:57 AM

Suggest you look into using a synonym for this.
Cool

How is that going to help with the permissions here Eirikur?

Create a schema and synonym in the destination database for the target table and grant select to the user/group on both the synonym and the target table, makes it transparent and the user/group can only do select.
Cool

As per your direction I got it working

what i tried

I created a schema TestSchema and TestSynonym in the destination database B. I had created view ViewA in database B referring to the schema TestSchema pointing to the table A in database A.
I had granted select permission on TestSynonym to the User A in database. After that i tried to grant select permissions on TableA in database A.

After that i tried to run the run the view ViewA in database B. It works.

But if I am giving read access directly on TableA in database A. I don't need Synonyms in Database B to create and let the user A use it in Database B. The read permissions on TableA in database A will itself be sufficient to run the viewA or directly read from the tableA.

Database A is very regulated database. Users should not have direct access to it. Indirect access is okay as long thet can't see the tables directly in DatabaseA

When i gave select permissions to the user A on TableA in database A. The user is directly able to see the TableA in database A. If he can see that he can query it directly.That is against the requirement.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search