SQL Release

Invoke-DlmDatabaseSchemaValidation

Invoke-DlmDatabaseSchemaValidation

Validates the schema and static data of a database scripts folder.

Syntax

Invoke-DlmDatabaseSchemaValidation [-InputObject] <string> [-TemporaryDatabaseServer <DatabaseServerConnection>] [-SQLCompareOptions <string>] [-QueryBatchTimeout <int>] [<CommonParameters>]

Invoke-DlmDatabaseSchemaValidation [-InputObject] <string> [-TemporaryDatabase <DatabaseConnection>] [-SQLCompareOptions <string>] [-QueryBatchTimeout <int>] [<CommonParameters>]

Description

The Invoke-DlmDatabaseSchemaValidation cmdlet validates the schema and static data of database scripts folder by checking the database can be built from scratch. It the validation is successful, the cmdlet creates a ValidatedSchemaSource object that represents the validated schema.

The cmdlet will throw an exception if the scripts folder contains invalid database schema or static data.

By default, the cmdlet creates a temporary copy of the database on LocalDB. Alternatively, you can use the TemporaryDatabaseServer parameter to specify a SQL Server instance for the temporary database. This is useful if your database uses features that aren't supported by LocalDB, such as Full-Text Search.

If you don't want to use LocalDB and don't have permission to create a database on the SQL Server instance, you can use the TemporaryDatabase parameter to specify an existing database.

Parameters

-InputObject <System.String>

The path to the database scripts folder to validate.

Aliases None
Required?true
Position?0
Default Value None
Accept Pipeline Inputtrue (ByValue)
Accept Wildcard Charactersfalse

-TemporaryDatabaseServer <RedGate.SQLRelease.Compare.SchemaSources.DatabaseServerConnection>

The connection string for the temporary database server used for validation. For example, 'Data Source=TempServer01'.

By default, SQL Release uses LocalDB for the temporary database. However there may be some features in your database that aren't supported by LocalDB (for example, Full-Text Search). In this case, or if LocalDB isn't present, use this parameter to specify an alternative SQL Server instance for the temporary database.

Using this option, SQL Release will create a temporary database on the specified SQL Server instance.

You can't use this parameter in addition to the TemporaryDatabase parameter.

Aliases None
Required?false
Position?named
Default Value None
Accept Pipeline Inputfalse
Accept Wildcard Charactersfalse

-TemporaryDatabase <RedGate.SQLRelease.Compare.SchemaSources.DatabaseConnection>

The details of the temporary database used for validation. This can be:

- an instance of a Database Connection object produced by the New-DlmDatabaseConnection cmdlet.

- a database connection string. For example, 'Data Source=TempServer01;Initial Catalog=TempDatabase01'.

By default, SQL Release uses LocalDB for the temporary database. If you don't want to use LocalDB and don't have permission to create a database on the SQL Server instance, use this option to specify an existing database to use for the temporary copy of the database.

If you use this parameter, all existing data on the temporary database will be lost.

You can't use this parameter in addition to the TemporaryDatabaseServer parameter.

Aliases None
Required?false
Position?named
Default Value None
Accept Pipeline Inputfalse
Accept Wildcard Charactersfalse

-SQLCompareOptions <System.String>

Specifies the SQL Compare options to use when creating the script for validation. SQL Release applies a default set of options, listed below. To include additional options, specify a comma-delimited list of the option names (eg 'IgnoreComments, ObjectExistenceChecks'). To turn off a default option, precede the option name with a minus sign (eg '-ForceColumnOrder').

This parameter will be ignored if the value specified is $null or empty.

By default, the following Compare options are used:

- ConsiderNextFilegroupInPartitionSchemes

- DecryptPost2KEncryptedObjects

- DoNotOutputCommentHeader

- ForceColumnOrder

- IgnoreCertificatesAndCryptoKeys

- IgnoreDatabaseAndServerName

- IgnoreUsersPermissionsAndRoleMemberships

- IgnoreUserProperties

- IgnoreWhiteSpace

- IgnoreWithElementOrder

- IncludeDependencies

- ThrowOnFileParseFailed

- UseCompatibilityLevel

For more information about SQL Compare options, see http://www.red-gate.com/sqlreleasecompareoptions.

Aliases None
Required?false
Position?named
Default Value None
Accept Pipeline Inputfalse
Accept Wildcard Charactersfalse

-QueryBatchTimeout <System.Int32>

The execution timeout, in seconds, for each batch of queries in the script for validation. The default value is 30 seconds. A value of zero indicates that no execution timeout will be enforced.

Aliases None
Required?false
Position?named
Default Value30
Accept Pipeline Inputfalse
Accept Wildcard Charactersfalse

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see http://technet.microsoft.com/en-us/library/hh847884.aspx.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.String

    The path to the database scripts folder to validate.

Return values

The output type is the type of the objects that the cmdlet emits.

  • RedGate.SQLRelease.Compare.SchemaValidation.ValidatedSchemaSource

Examples

---------- EXAMPLE 1 ----------

$scriptsFolder = "C:\Work\scripts"
$validatedSchema = $scriptsFolder | Invoke-DlmDatabaseSchemaValidation

This example shows how to use the Invoke-DlmDatabaseSchemaValidation cmdlet to validate the schema and static data of a scripts folder.

A temporary copy of the database is created on LocalDB. If the scripts folder content is invalid, this operation will throw an exception. Otherwise, it will output an instance of a ValidatedSchemaSource object that can be used as the input for other SQL Release cmdlets.

---------- EXAMPLE 2 ----------

$scriptsFolder = "C:\Work\scripts"
$validatedSchema = $scriptsFolder | Invoke-DlmDatabaseSchemaValidation -TemporaryDatabaseServer "Data Source=.\SQL2014"

This example shows how to specify a SQL Server instance for the temporary database, instead of using LocalDB.

This is useful if your database uses features that aren't supported by LocalDB, such as Full-Text Search.

---------- EXAMPLE 3 ----------

$scriptsFolder = "C:\Work\scripts"
$temporaryDatabase = New-DlmDatabaseConnection -ServerInstance ".\SQL2014" -Database "TemporaryDb"
$validatedSchema = $scriptsFolder | Invoke-DlmDatabaseSchemaValidation -TemporaryDatabase $temporaryDatabase

This example shows how to specify an existing SQL Server database to use for the validation.

This is useful if you don't want to use LocalDB and you don't have permission to create a database on the SQL Server instance.

---------- EXAMPLE 4 ----------

$scriptsFolder = "C:\Work\scripts"
$options = "IgnoreComments, ObjectExistenceChecks, -IgnoreUserProperties"
$validatedSchema = $scriptsFolder | Invoke-DlmDatabaseSchemaValidation -SQLCompareOptions $options

This example shows how to specify SQL Compare options to be used when creating the script for validation.

The $options variable is used to specify that the IgnoreComments and ObjectExistenceChecks options should be included in addition to the default set of SQL Compare options used by this cmdlet. The minus sign before IgnoreUserProperties indicates that this default option will be turned off.


Didn't find what you were looking for?