SqlServerDbaServices
Provides DBA services for Microsoft SQL Server.
- Namespace:
- KpokPatagon.Data.SqlServer.Dba
- Type:
- Class
- Public:
- Yes
- Protected:
- No
- Sealed:
- Yes
- Abstract:
- No
Constructors
Properties
DatabaseApi
Database communication API.
- Signature:
public IDbAccess DatabaseApi { get; }
Methods
ChangeLoginPassword
Changes the login password.
- Signature:
public Void ChangeLoginPassword(login)
Parameters
Name |
Type |
Summary |
login |
Login |
A Login to create. |
Exceptions
Type |
Summary |
ValidationException |
Thrown when login does not have the required configuration. |
ArgumentNullException |
Thrown when login is null. |
SchemaManipulationException |
Thrown when an error occurs while manipulating the database. |
CreateDatabase
Creates a new database.
- Signature:
public Void CreateDatabase(name, collate, autoCloseOff, autoShrinkOff)
Parameters
Name |
Type |
Summary |
name |
String |
Name of the database. |
collate |
String |
Collation for the database (optional). |
autoCloseOff |
Boolean |
Whether to issue an AUTO_CLOSE OFF command. |
autoShrinkOff |
Boolean |
Whether to issue an AUTO_SHRINK OFF command. |
Exceptions
CreateLogin
Creates a new login.
- Signature:
public Void CreateLogin(login)
Parameters
Name |
Type |
Summary |
login |
Login |
A Login to create. |
Exceptions
Type |
Summary |
ValidationException |
Thrown when login does not have the required configuration. |
ArgumentNullException |
Thrown when login is null. |
SchemaManipulationException |
Thrown when an error occurs while manipulating the database. |
CreateUser
Creates a user for login in the database database
and adds the user to the specified roles.
- Signature:
public Void CreateUser(userName, login, database, roles)
Parameters
Name |
Type |
Summary |
userName |
String |
Name of the user to add. |
login |
String |
Name of the login the user is added for. |
database |
String |
Name of the database to add the user to. |
roles |
UserRoles |
User roles to be granted to the new user. |
Exceptions
DropDatabase
Drops a database.
- Signature:
public Void DropDatabase(name)
Parameters
Name |
Type |
Summary |
name |
String |
Name of the database to drop. |
Exceptions
DropLogin
Drops a login.
- Signature:
public Void DropLogin(name)
Parameters
Name |
Type |
Summary |
name |
String |
Name of the login to drop. |
Exceptions
DropSchema
Drops a schema in the database.
- Signature:
public Void DropSchema(name, database)
Parameters
Name |
Type |
Summary |
name |
String |
Name of the schema. |
database |
String |
Name of the database. |
Exceptions
DropUser
Drops a user named name from the database.
- Signature:
public Void DropUser(name, database)
Parameters
Name |
Type |
Summary |
name |
String |
Name of the user to drop. |
database |
String |
Name of the database from where the user is dropped. |
Exceptions
ExistsDatabase
Checks whether a database exists on the server.
- Signature:
public Boolean ExistsDatabase(name)
Returns
true if the database exists, otherwise false.
Parameters
Name |
Type |
Summary |
name |
String |
Name of the database to check. |
Exceptions
ExistsLogin
Checks whether a login exists.
- Signature:
public Boolean ExistsLogin(name)
Returns
true if the login exists, otherwise false.
Parameters
Name |
Type |
Summary |
name |
String |
Name of the login to check. |
Exceptions
ExistsUser
Checks whether a user exists within a database.
- Signature:
public Boolean ExistsUser(userName, databaseName)
Returns
true if the user exists within the database, otherwise false.
Parameters
Name |
Type |
Summary |
userName |
String |
Name of the user to verify. |
databaseName |
String |
Name of the database to which the user belongs. |
Exceptions
GetServerRoles
Gets the server roles for the spacified userName.
- Signature:
public ServerRoles GetServerRoles(userName)
Returns
A flagged enumeration of the user server roles.
Parameters
Name |
Type |
Summary |
userName |
String |
Name of the user to get it's server roles. |
Exceptions