Author | Jana Sattainathan (@SQLJana), sqljana.wordpress.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Find-DbaSimilarTable on GitHub.
Want to see the Bill Of Health for this command? Check out Find-DbaSimilarTable.
Returns all tables/views that are similar in structure by comparing the column names of matching and matched tables/views
This function can either run against specific databases or all databases searching all/specific tables and views including in system databases.
Typically one would use this to find for example archive version(s) of a table whose structures are similar.
This can also be used to find tables/views that are very similar to a given table/view structure to see where a table/view might be used.
More information can be found here: https://sqljana.wordpress.com/2017/03/31/sql-server-find-tables-with-similar-table-structure/
Find-DbaSimilarTable
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[[-SchemaName] <String>]
[[-TableName] <String>]
[-ExcludeViews]
[-IncludeSystemDatabases]
[[-MatchPercentThreshold] <Int32>]
[-EnableException]
[<CommonParameters>]
PS C:\> Find-DbaSimilarTable -SqlInstance DEV01
Searches all user database tables and views for each, returns all tables or views with their matching tables/views and match percent
PS C:\> Find-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks
Searches AdventureWorks database and lists tables/views and their corresponding matching tables/views with match percent
PS C:\> Find-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -SchemaName HumanResource
Searches AdventureWorks database and lists tables/views in the HumanResource schema with their corresponding matching tables/views with match percent
PS C:\> Find-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -SchemaName HumanResource -Table Employee
Searches AdventureWorks database and lists tables/views in the HumanResource schema and table Employee with its corresponding matching tables/views with match percent
PS C:\> Find-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -MatchPercentThreshold 60
Searches AdventureWorks database and lists all tables/views with its corresponding matching tables/views with match percent greater than or equal to 60
The target SQL Server instance or instances. This can be a collection and receive pipeline input
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
If you are looking in a specific schema whose table structures is to be used as reference structure, provide the name of the schema.
If no schema is provided, looks at all schemas
Alias | |
Required | False |
Pipeline | false |
Default Value |
If you are looking in a specific table whose structure is to be used as reference structure, provide the name of the table.
If no table is provided, looks at all tables
If the table name exists in multiple schemas, all of them would qualify
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default, views are included. You can exclude them by setting this switch to $false
This excludes views in both matching and matched list
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
By default system databases are ignored but you can include them within the search using this parameter
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
The minimum percentage of column names that should match between the matching and matched objects.
Entries with no matches are eliminated
Alias | |
Required | False |
Pipeline | false |
Default Value | 0 |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |