Enabling/disabling change tracking
This recipe shows you how you can enable and disable change tracking to your target database.
Getting ready
In this recipe, we
will use a test database called TestDB
. If you don't already have this database, log in to SQL Server Management Studio and execute the following T-SQL code:
IF DB_ID('TestDB') IS NULL CREATE DATABASE TestDB GO
Check which of your databases have change tracking enabled. Connect to your instance using SQL Server Management Studio, and type in this T-SQL statement:
SELECT DB_NAME(database_id) AS 'DB', * FROM sys.change_tracking_databases
How to do it...
Open the PowerShell console by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Import the
SQLPS
module, and create a new SMO Server object as follows:#import SQL Server module Import-Module SQLPS -DisableNameChecking #replace this with your instance name $instanceName = "KERRIGAN" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList...