Grant Method (Database)
未來的 Microsoft SQL Server 版本將移除這項功能。請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。
The Grant method assigns a database permission or a list of permissions to one or more Microsoft SQL Server users or roles.
語法
object
.Grant(
Privilege
,
GranteeNames
)
Parts
object
Expression that evaluates to an object in the Applies To list.Privilege
Long integer that specifies one or more database permissions as described in Settings.GranteeNames
SQL Distributed Management Objects (SQL-DMO) multistring listing users or roles.
Prototype (C/C++)
HRESULT Grant(
SQLDMO_PRIVILEGE_TYPE iPrivileges,
SQLDMO_LPCSTR GranteeNames);
Settings
Set Privilege using these SQLDMO_PRIVILEGE_TYPE values.
Constant |
Value |
Description |
---|---|---|
SQLDMOPriv_/AllDatabasePrivs |
130944 |
Grant all database permissions to the users or roles listed. |
SQLDMOPriv_CreateDatabase |
256 |
Grant the execute permission for the CREATE DATABASE statement. |
SQLDMOPriv_CreateDefault |
4096 |
Grant the execute permission for the CREATE DEFAULT statement. |
SQLDMOPriv_CreateFunction |
65366 |
Can create and own UserDefinedFunction objects. |
SQLDMOPriv_CreateProcedure |
1024 |
Can create and own StoredProcedure objects. |
SQLDMOPriv_CreateRule |
16384 |
Grant the execute permission for the CREATE RULE statement. |
SQLDMOPriv_CreateTable |
128 |
Grant the execute permission for the CREATE TABLE statement. |
SQLDMOPriv_CreateView |
512 |
Grant the execute permission for the CREATE VIEW statement. |
SQLDMOPriv_DumpDatabase |
2048 |
Grant permission to back up database. |
SQLDMOPriv_DumpTable |
32768 |
Maintained for compatibility with previous versions of SQL-DMO. |
SQLDMOPriv_/DumpTransaction |
8192 |
Grant permission to back up the database transaction log. |
備註
Granting permissions to database users and roles using the Grant method of the Database object requires appropriate permissions. The Microsoft SQL Server login used for SQLServer object connection must be a member of the system-defined role sysadmin.
For more information about setting multistring parameters, see Using SQL-DMO Multistrings.