Skip to content

Latest commit

 

History

History
147 lines (117 loc) · 4.27 KB

File metadata and controls

147 lines (117 loc) · 4.27 KB

DSC Resource 'SqlDatabases'

SqlDatabases creates and manages SQL Server databases.

When to use 'SqlDatabases'

Use this resource when you need to create databases on a SQL Server instance. It handles database creation with configurable collation and recovery model. Use this for provisioning application databases as part of your infrastructure deployment.

For more information about SQL Server databases, please read the following articles Create a Database and Delete a Database.

This resource sets the recovery model for a database. The recovery model controls how transactions are logged, whether the transaction log requires (and allows) backing up, and what kinds of restore operations are available. Three recovery models exist: full, simple, and bulk-logged. Read more about recovery model in the article View or Change the Recovery Model of a Database.

Source

DSC Resource

Documentation

Requirements
  • Target machine must be running Windows Server 2012 or later.

  • Target machine must be running SQL Server Database Engine 2012 or later.

  • Valid values per SQL Server version for the parameter CompatibilityLevel can be found in the article ALTER DATABASE (Transact-SQL) Compatibility Level.

Table 1. Attributes of category 'SqlDatabases'
Parameter Attribute DataType Description Allowed Values

DefaultInstanceName

String

Default SQL InstanceName
If the InstanceName of a value is not explicitly set, the DefaultInstanceName will be used.

Default: MSSQLSERVER

Values

Mandatory

Hashtable[]

List of SQL databases.

Table 2. Attributes of category 'SqlDatabases'
Parameter Attribute DataType Description Allowed Values

Name

Key

String

The name of the SQL Server database.

InstanceName

Key

String

The name of the SQL Server instance to be configured.

Ensure

String

Determines whether the database should be added ('Present') or removed ('Absent'). Default value is 'Present'.

Present, Absent

ServerName

String

The host name of the SQL Server to be configured. Default value is the current computer name.

Collation

String

The name of the collation to use for the new database. Default value is the collation used by the server.

CompatibilityLevel

String

Specifies the version of the SQL Database Compatibility Level to use for the specified database.

Version80, Version90, Version100, Version110, Version120, Version130, Version140, Version150

RecoveryModel

String

The recovery model for the specified database.

Simple, Full, BulkLogged

Example
SqlDatabases:
  Values:
    - Name: MyDatabase1
      InstanceName: MSSQLSERVER
      ServerName: SQL1
    - Name: MyDatabase2
      InstanceName: MSSQLSERVER
      ServerName: SQL1
      Collation: SQL_Latin1_General_CP1_CI_AS
      RecoveryModel: Full