Author | Chrissy LeMaire (@cl) , SmartTarget by Gianluca Sartori (@spaghettidba) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out New-DbaXESmartTableWriter on GitHub.
Want to see the Bill Of Health for this command? Check out New-DbaXESmartTableWriter.
This response type is used to write Extended Events to a database table.
This response type is used to write Extended Events to a database table. The events are temporarily stored in memory before being written to the database at regular intervals.
The target table can be created manually upfront or you can let the TableAppenderResponse create a target table based on the fields and actions available in the events captured.
The columns of the target table and the fields/actions of the events are mapped by name (case-sensitive).
New-DbaXESmartTableWriter
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[-Database] <String>
[-Table] <String>
[-AutoCreateTargetTable]
[[-UploadIntervalSeconds] <Int32>]
[[-Event] <String[]>]
[[-OutputColumn] <String[]>]
[[-Filter] <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> $columns = "cpu_time", "duration", "physical_reads", "logical_reads", "writes", "row_count", "batch_text"
PS C:\> $response = New-DbaXESmartTableWriter -SqlInstance sql2017 -Database dbadb -Table deadlocktracker -OutputColumn $columns -Filter "duration > 10000"
PS C:\> Start-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response
Writes Extended Events to the deadlocktracker table in dbadb on sql2017.
The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
Specifies the name of the database that contains the target table.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Specifies the name of the target table.
Alias | |
Required | True |
Pipeline | false |
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 |
If this switch is enabled, XESmartTarget will infer the definition of the target table from the columns captured in the Extended Events session.
If the target table already exists, it will not be recreated.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Specifies the number of seconds XESmartTarget will keep the events in memory before dumping them to the target table. The default is 10 seconds.
Alias | |
Required | False |
Pipeline | false |
Default Value | 10 |
Specifies a list of events to be processed (with others being ignored. By default, all events are processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the list of columns to output from the events. XESmartTarget will capture in memory and write to the target table only the columns (fields or targets) that are present in this list.
Fields and actions are matched in a case-sensitive manner.
Expression columns are supported. Specify a column with ColumnName AS Expression to add an expression column (Example: Total AS Reads + Writes)
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies a filter expression in the same form as you would use in the WHERE clause of a SQL query.
Example: duration > 10000 AND cpu_time > 10000
Alias | |
Required | False |
Pipeline | false |
Default Value |
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 |
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |