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:

  1. Open PowerShell ISE as an administrator.
  2. Import ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.