Link to home
Start Free TrialLog in
Avatar of Marcus Aurelius
Marcus AureliusFlag for United States of America

asked on

SQL Server 2012 - How to Grant Access to a Schema for ALL USERS?

What is the syntax for me Granting Access to a newly created SCHEMA? I want all users to be able to do anything within this Schema.
Avatar of lcohan
lcohan
Flag of Canada image

USE [YourDB]
GO
CREATE ROLE [SchemaAccess] AUTHORIZATION [YourSchemaNameHere]
GO

ALTER AUTHORIZATION ON SCHEMA::[YourSchemaNameHere] TO [SchemaAccess]
GO

--or to create new schema

CREATE SCHEMA [YourSchemaNameHere1] AUTHORIZATION [SchemaAccess]
GO


--then just add all users you want to that [SchemaAccess] DB Role - you can put this in a dynamic sql.

sp_addrolemember 'SchemaAccess', 'User1'
sp_addrolemember 'SchemaAccess', 'User2'

...
sp_addrolemember 'SchemaAccess', 'UserN'
If your Public server role is active:
GRANT CONTROL ON SCHEMA :: YourSchema TO PUBLIC;

Open in new window

Hi,

Russell Fox is right, you can also use it:

Granting SELECT permission on schema Person to database user JILL

GRANT CONTROL ON SCHEMA :: YOURSCHEMA TO JILL

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial