How do I create a new role in my database with my first name which is Denise, and add read only access on the HR user's EMPLOYEES table to this role.

  • 1
    What DBMS are you working with (SQL Server, MySQL, Oracle)? It differes just a bit depending on which DBMS you are referring to. Are you looking for T-SQL code or do it through a GUI or management tools? – user507 Jul 23 '11 at 3:08
  • Wouldn't the t-sql tag indicate the DBMS? – Quick Joe Smith Jul 23 '11 at 4:56
  • Well the OP tagged it with clustered-index, which has really nothing to do with the question. I would assume SQL Server is the DBMS but other DBMS questions show up on this site so I just put t-sql for now. – user507 Jul 23 '11 at 5:44

Using Adventureworks database as a reference, following shows sudo code

USE [AdventureWorks] 
USE [AdventureWorks]  
GRANT SELECT ON [HumanResources].[Employee] TO [Denise]

From the documentation on MSDN for Create Role and Grant select

create role denise identified by appropriateVariable;

grant select on HR.employees to denise;
  • 6
    I'm torn here. I want to welcome another dba to the fold, but this answer is ... less than helpful. I've rewritten it a bit to show you no hard feelings. Welcome to the site, but can we try and put a tad more effort into the posts? :) – jcolebrand Jul 23 '11 at 3:50
  • 4
    This syntax isn't SQL Server... – gbn Oct 8 '11 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.