sql server grant, revoke permission to a user

后端 未结 3 1913
挽巷
挽巷 2021-01-25 19:15

I wrote a simple c# code that connect to sql-server database and execute a query:

        cmd = new SqlCommand(txtQuery.Text.ToString().Trim(), con);
        cmd         


        
3条回答
  •  旧巷少年郎
    2021-01-25 19:43

    user2 is probably getting it's permissions from a role membership.

    Run:

    use []
    GO
    
    exec sp_helpuser
    

    find the user in the first column, and then look at the second column. Is the user a member of db_datareader or db_owner?

    If so, you can revoke membership, say for db_datareader, by doing:

    exec sp_droprolemember 'db_datareader', 'user2'
    GO
    

提交回复
热议问题