Enabling/disabling change tracking
This recipe shows you how you can enable and disable change tracking in your target database.
Getting ready
In this recipe, we will use a test database called TestDB
. If you do not 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
You need to check which of your databases have change tracking enabled. To do this, connect to your instance using SQL Server Management Studio, and type in the following T-SQL statement:
SELECT DB_NAME(database_id) AS 'DB', * FROM sys.change_tracking_databases
How to do it...
To enable/disable change tracking, perform the following steps:
- Open PowerShell ISE as an administrator.
- 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 = "localhost" $server = New...