I have multiple views and want to create more views in SQL Server. I want to grant select rights automatically to some users as I create view. Kindly mention code.
I have multiple views and want to create more views in SQL Server. I want to grant select rights automatically to some users as I create view. Kindly mention code.
Hi,
If these users currently do not have permission to access the view object.
For the existing view, you can go to the Properties of the view in SSMS, add users in the Permissions, and then grant select permission in the permissions list. Or use the following statement to grant user permissions:
use YourDB
GRANT SELECT ON OBJECT::[schema].[yourview] TO User1,User2
For views to be created in the future, you cannot grant user any permission while creating them. You can choose to grant permissions after creating views.
Or create a new schema for these views, and grant these users the right to select objects in this schema .It is necessary to ensure that the owner of the schema of the original tables and the schema where the view is located are the same.
use YourDB
GRANT select ON Schema :: [DBO] TO User1
Note that you can GRANT SELECT permissions on a Schema, but you are unable to limit the SELECT privileges to views only.
Hi @Hazir-3393,
we have not get a reply from you. Did any answers could help you? If there have any answers helped you, please do "Accept Answer". If not, please let us know. By doing so, it will benefit for community members who have this similar issue. Your contribution is highly appreciated. Thank you!
10 people are following this question.
Year and Month aggregation in same Pivot table in SQL Server
SQL Server Query for Searching by word in a string with word breakers
How to show first row group by part id and compliance type based on priorities of Document type?
Query to list all the databases that have a specific user
T-sql query to find the biggest table in a database with a clustered index