grant permissions

  • i got a database named sqlbox

    and a user named sam

    and i want to grant select permissions to sam on that database sqlbox.

    what is the query to set that permissions

  • USE sqlbox

    GO

    EXEC sp_addrolemember N'db_datareader', N'sam'

    GO


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Or you can use the Grant Select command:

    USE sqlbox

    GO

    GRANT SELECT ON sqlbox TO sam

    GO

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • Dugi is correct - it is best practice to grant least privileges - though I rarely manipulate permissions per user. It usually makes more sense to grant to a group or role, and add the user to that.

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

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