Please ensure you're running PowerShell version 3.0+
PS C:\>Import-Module .\TableDiffTools.psd1
To verify the module is loaded
PS C:\>Get-Module -Name "TableDiffTools"
The following is a list of commands which are available
Command | Description |
---|---|
Compare-Table | Execute tablediff to compere and find differences in table between 2 databases |
Get-Table | Populate table and schema name from database |
To retrieve tables by specific schema
PS C:\>Get-Table -Server <server> -Database <database> -FilterBySchema "Foo","Bar"
To retrieve tables participate in replication only
PS C:\>Get-Table -Server <server> -Database <database> -IsReplicated
To compare single table
PS C:\>Compare-Table `
-SourceTable "Foo.Config" `
-SourceServer "<sourceserver>" `
-SourceDatabase "<sourcedatabase>" `
-TableDiffTool "C:\Program Files\Microsoft SQL Server\120\COM\tablediff.exe" `
-DestinationServer "<destServer>" `
-DestinationDatabase "<destdatabase>" `
-OutputLocation "D:\Tablediff"
To compare tables by populating table detail from database using Get-Table cmdlet
PS C:\>$tables = Get-Table -Server <server> -Database <database> -IsReplicated
PS C:\>$tables | Compare-Table `
-SourceServer "<sourceserver>" `
-SourceDatabase "<sourcedatabase>" `
-TableDiffTool "C:\Program Files\Microsoft SQL Server\120\COM\tablediff.exe" `
-DestinationServer "<destServer>" `
-DestinationDatabase "<destdatabase>" `
-OutputLocation "D:\Tablediff"
To compare tables by specific tables name
PS C:\>$table = @('Foo.Info','Bar.Config')
PS C:\>$tables | Compare-Table `
-InputTable $table
-SourceServer "<sourceserver>" `
-SourceDatabase "<sourcedatabase>" `
-TableDiffTool "C:\Program Files\Microsoft SQL Server\120\COM\tablediff.exe" `
-DestinationServer "<destServer>" `
-DestinationDatabase "<destdatabase>" `
-OutputLocation "D:\Tablediff"