SQL Server 2005 db_denydatawriter example query
I'm tryin开发者_Python百科g to add mydomain\myuser to the db_denydatawriter role but i can find a simple example of the query does anybody have a quick example?
3 steps, in case you haven't set up login + user already
CREATE LOGIN [mydomain\myuser] FROM WINDOWS;
at the server level. MSDNCREATE USER [mydomain\myuser] FROM LOGIN [mydomain\myuser];
at the db level. MSDN- Match user to role
EXEC sp_addrolemember 'mydomain\myuser', 'db_denydatawriter'
Edit:
This only prevents INSERT, UPDATE and DELETE directly on the tables
It won't stop changing table design. That is ddl_admin or db_owner. db_owner rights override all other permissions so deny will have no effect.
If writes are via stored procs, ownership chaining means permissions are not checked on a table. So this answer won't work.
EXEC sp_addrolemember N'db_denydatawriter', N'Foo'
Reference here.
精彩评论