5

I want to add new custom SQL Server Role and assign the new users to these appropriate roles respectively. I try to find how to create role, but I could not find the place to add that. Could you please guide me how to achieve my requirement?

1
  • Do you mean in a database or at the server level? SPE109 has a good point, I and marc_s may have mis-understood Commented Jun 2, 2011 at 10:23

5 Answers 5

7

You cannot do this in the 2008 version just yet - this is a new feature that you'll get with SQL Server 2011 (a.k.a. "Denali") sometime in 2011/2012.

See some resources:

Sign up to request clarification or add additional context in comments.

Comments

4

You'd simply GRANT the rights you want to a login rather than a role pre SQL Server 2011. Not ideal of course but it works.

We use this to enable app teams to see what is going on without hassling the DBAs.

For example,

CREATE LOGIN [MyDOmain\FolkITrustGroup] FROM WINDOWS;
GO
GRANT VIEW SERVER STATE TO  [MyDOmain\FolkITrustGroup]
GRANT VIEW ANY DEFINITION TO  [MyDOmain\FolkITrustGroup]
GO

Edit: This achieves your requirement without using server roles which don't exist yet...

Comments

0

You can create Database level roles see Create Role and the links on the page for more detail.

2 Comments

This isn't a server role as OP asked
Did they? It's not clear to me whether he asked about creating a server level or database level role, they only asked about creating a role in SQL Server.
0

Well I don't have SQL server installed right now so I can't check. But my knowledge of SQL tells me :

creating a role :

create role <rolename>;

granting privilages :

grant <privilages> on <relation> to <rolename>;

revoking privilages :

revoke <priv> on <rel> from <rolename>;

grant role to user :

grant <rolename> to user;

You can also create the hierarchy of it : e.g.>

create role supervisor;
grant select, insert on db.table to supervisor;
create role manager;
grant supervisor to manager;

grant manager to John;

This is the standard SQL way. It is not available yet in current versions of some DBMS. Not sure about SQL server.

1 Comment

The last statement is wrong. It should be: EXEC sp_addrolemember 'manager', 'John'
-1
****A. Creating a server role that is owned by a login****


****The following example creates the server role buyers that is owned by login BenMiller.****

USE master;
CREATE SERVER ROLE buyers AUTHORIZATION BenMiller;
GO


****B. Creating a server role that is owned by a fixed server role****


****The following example creates the server role auditors that is owned the securityadmin fixed server role.****

USE master;
CREATE SERVER ROLE auditors AUTHORIZATION securityadmin;
GO

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.