Grant Method (Database) (SQL-DMO)

The Grant method assigns a database permission or a list of permissions to one or more Microsoft® SQL Server™ users or roles.

Applies To

Database Object

Syntax

object.Grant( Privilege , GranteeNames )

Part Description
object Expression that evaluates to an object in the Applies To list
Privilege Long integer specifying one or more database permissions as described in Settings
GranteeNames SQL-DMO multistring listing users or roles

Settings
Constant Value Description
SQLDMOPriv_AllDatabasePrivs 65408 Grant all database privilege to the users or roles listed
SQLDMOPriv_CreateDatabase 256 Grant execute permission for  the CREATE DATABASE statement
SQLDMOPriv_CreateDefault 4096 Grant execute permission for  the CREATE DEFAULT statement
SQLDMOPriv_CreateProcedure 1024 Grant execute permission for  the CREATE PROCEDURE permission
SQLDMOPriv_CreateRule 16384 Grant execute permission for  the CREATE RULE statement
SQLDMOPriv_CreateTable 128 Grant execute permission for  the CREATE TABLE statement
SQLDMOPriv_CreateView 512 Grant 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

Remarks

Granting permissions to database users and roles by using the Grant method of the Database object requires appropriate privilege. The Microsoft® SQL Server™ login used for SQLServer object connection must be a member of the system-defined role sysadmin.

Prototype (C/C++)

HRESULT Grant(
SQLDMO_PRIVILEGE_TYPE iPrivileges,
SQLDMO_LPCSTR GranteeNames);

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.