4

I don't want to create roles and play that way at the moment - just trying to get a Q&D on this. When I execute:

grant all to [LameDomain\CoolDude]

I get the DB barking that (a) the command is deprecated (kept for compatibility reasons only) and that (b) I can't do this to myself (and that's the real problem). NB, I'm the cool dude in the lame domain.

So, my questions are (in raising order of importance) as follows.

  1. What syntax can be used to grant all the privileges to self (one-liner if possible)?
  2. If necessary, what's the recommended syntax one should use to grant all to self?
  3. What's the current version of the command "grant all to XXX"?

EDIT

When I try to follow this article, I get the error that the user or role doesn't exist in the DB, when I try to execute sp_addrolemember. However, when attempting to call sp_grantdbaccess, I get that the user already has a name in the DB. WTF?!

4

1 回答 1

1

您可以将用户添加到系统角色db_owner。这样,用户将拥有包括ALTERCREATE对象在内的数据库的所有权限。

db_owner 固定数据库角色的成员可以对数据库执行所有配置和维护活动。

USE_database_name
GO
EXEC sp_addrolemember 'db_owner', 'user_name'
GO

至于GRANT ALL您仍然可以使用它,但它不会授予所有权限。您可以在GRANT的文档中查看将授予的权限列表

于 2013-07-24T07:48:38.830 回答