dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Get-DbaSchemaChangeHistory

Queries the default system trace for any DDL changes in the specified timeframe.
Only works with SQL 2005 and later, as the system trace didn’t exist before then.

Screenshots

dbatools-Get-DbaSchemaChangeHistory

Examples

Returns all DDL changes made in all databases on the SQL Server instance localhost since the system trace began.

Get-DbaSchemaChangeHistory -SqlInstance localhost

Returns all DDL changes made in all databases on the SQL Server instance localhost in the last 7 days.

Get-DbaSchemaChangeHistory -SqlInstance localhost -Since (Get-Date).AddDays(-7)

Returns all DDL changes made in the Prod and Finance databases on the SQL Server instance localhost in the last 7 days.

Get-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance, Prod -Since (Get-Date).AddDays(-7)

Returns all DDL changes made to the AccountsTable object in the Finance database on the SQL Server instance localhost in the last 7 days

Get-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance -Object AccountsTable -Since (Get-Date).AddDays(-7)

Author

This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.

Get-Help

From PowerShell, execute Get-Help Get-DbaSchemaChangeHistory -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaSchemaChangeHistory.ps1 on GitHub
 

Related commands