I'm working with
Microsoft SQL Server 2019 (RTM-GDR) - 15.0.2095.3 (X64) Apr 29 2022 18:00:13
Copyright (C) 2019 Microsoft Corporation
Standard Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)
I want to give a user rights to only CREATE and DROP VIEWS and deny rights to CREATE and DROP tables, schemas, or the whole database.
Is there a combination on the permissions level available to achieve this? So far all I found was that ALTER rights on the schema are required to create views, which however also gives users rights to actions I want to deny them.
The background is that we want to give users read-only rights to the database with the exception of creating and deleting views.
As I mentioned in my (now deleted) comments, using a schema might be the easier solution here. Although you can give a
USERpermissions to explicitlyCREATEaVIEWtheALTERcan't be an granular. Instead, however, you could give them access to a specific schema and then they can create (andALTER) their views as they see fit. This is a "quick" example demonstrating the method:The above will both
CREATEandALTERtheVIEWV.RelatedRows, while failing to create theVIEWdbo.NoAccess. As noted as well, I don't give explicit access todboschema to theUSER, they can only access the data through permission chaining. That may not be desired, but I wanted to demonstrate that the user doesn't actually even need direct access to the table to be able to be able to use it in this scenario.