< Back

New-DbaXESmartTableWriter

Mon Jan 13, 2020 1:04 pm

NAME New-DbaXESmartTableWriter



SYNOPSIS

This response type is used to write Extended Events to a database table.





SYNTAX

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

[[-SqlCredential] <Pscredential>] [-Database] <String> [-Table] <String> [-AutoCreateTargetTable <Switch>]

[[-UploadIntervalSeconds] <Int>] [[-Event] <System.String[]>] [[-OutputColumn] <System.String[]>] [[-Filter]

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





DESCRIPTION

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).





PARAMETERS

-AutoCreateTargetTable [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Database [<String>]

Specifies the name of the database that contains the target table.



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



-Event [<System.String[]>]

Specifies a list of events to be processed (with others being ignored. By default, all events are processed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Filter [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-OutputColumn [<System.String[]>]

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)



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. You must have sysadmin access and server version must be SQL

Server version 2008 or higher.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Table [<String>]

Specifies the name of the target table.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-UploadIntervalSeconds [<Int>]

Specifies the number of seconds XESmartTarget will keep the events in memory before dumping them to the target

table. The default is 10 seconds.



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: ExtendedEvent, XE, XEvent, SmartTarget

Author: Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)



Website: https://dbatools.io

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

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

SmartTarget: by Gianluca Sartori (@spaghettidba)



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



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.



RELATED LINKS

https://dbatools.io/New-DbaXESmartTableWriter