Add Database Fixed Roles to a Database Role

  • I shy away from SQL Server Authentication but in this case I have to use it.

    I created the following Roles:

    CREATE ROLE DatabaseUser

    CREATE ROLE DatabaseDeveloper

    Now I want to assign db_datareader Database Fixed Role to the DatabaseUser Role.

    I also want to assign the db_datareader, db_datawriter and db_DDLAdmin Database Fixed Roles to the DatabaseDeveloper Role that I created

    Could someone please tell me the syntax. I had to work on another project and I need to set up by COB?

    Thanks.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • here you go:

    CREATE ROLE DatabaseUser

    EXEC sp_addrolemember N'db_datareader', N'DatabaseUser'

    CREATE ROLE DatabaseDeveloper

    EXEC sp_addrolemember N'db_ddladmin', N'DatabaseDeveloper'

    EXEC sp_addrolemember N'db_datareader', N'DatabaseDeveloper'

    EXEC sp_addrolemember N'db_datawriter', N'DatabaseDeveloper'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Rings a bell.:-)

    Thanks Lowell!

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply