< Back

Get-DbaDbTable

Mon Jan 13, 2020 10:57 am

NAME Get-DbaDbTable



SYNOPSIS

Returns a summary of information on the tables





SYNTAX

Get-DbaDbTable [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [[-Database] <System.String[]>] [[-ExcludeDatabase] <System.String[]>] [-IncludeSystemDBs

<Switch>] [[-Table] <System.String[]>] [[-InputObject] <Microsoft.SqlServer.Management.Smo.Database[]>]

[-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Shows table information around table row and data sizes and if it has any table type information.





PARAMETERS

-Database [<System.String[]>]

The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will

be processed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ExcludeDatabase [<System.String[]>]

The database(s) to exclude - this list is auto-populated from the server



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-IncludeSystemDBs [<Switch>]

Switch parameter that when used will display system database information



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<Microsoft.SqlServer.Management.Smo.Database[]>]

Enables piping from Get-DbaDatabase



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances. This can be a collection and receive pipeline input.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Table [<System.String[]>]

Define a specific table you would like to query. You can specify up to three-part name like db.sch.tbl.



If the object has special characters please wrap them in square brackets [ ].

Using dbo.First.Table will try to find table named 'Table' on schema 'First' and database 'dbo'.

The correct way to find table named 'First.Table' on schema 'dbo' is by passing dbo.[First.Table]

Any actual usage of the ] must be escaped by duplicating the ] character.

The correct way to find a table Name] in schema Schema.Name is by passing [Schema.Name].[Name]]]



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Database, Tables

Author: Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-DbaDbTable -SqlInstance DEV01 -Database Test1



Return all tables in the Test1 database

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-DbaDbTable -SqlInstance DEV01 -Database MyDB -Table MyTable



Return only information on the table MyTable from the database MyDB

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-DbaDbTable -SqlInstance DEV01 -Table MyTable



Returns information on table called MyTable if it exists in any database on the server, under any schema

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Get-DbaDbTable -SqlInstance DEV01 -Table dbo.[First.Table]



Returns information on table called First.Table on schema dbo if it exists in any database on the server

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>'localhost','localhost\\namedinstance' | Get-DbaDbTable -Database DBA -Table Commandlog



Returns information on the CommandLog table in the DBA database on both instances localhost and the named instance

localhost\\namedinstance

-------------------------- EXAMPLE 6 --------------------------



PS C:\\>Get-DbaDbTable -SqlInstance DEV01 -Table "[[DbName]]].[Schema.With.Dots].[`"[Process]]`"]" -Verbose



For the instance Dev01 Returns information for a table named: "[Process]" in schema named: Schema.With.Dots in

database named: [DbName]

The Table name, Schema name and Database name must be wrapped in square brackets [ ]

Special charcters like " must be escaped by a ` charcter.

In addition any actual instance of the ] character must be escaped by being duplicated.



RELATED LINKS

https://dbatools.io/Get-DbaDbTable