I have an event session which created files I would like to import into a table, I want to have the columns I watched showing columns on the table I am importing into one of which is post execution query plan.
Is there a automatic way of generating the sql that would do the import reading from sys.fn_xe_file_target_read_file file so that I do not have to hand write similar queries for different extended event sessions also?
Thank you
CREATE EVENT SESSION [ServiceAccount] ON SERVER ADD EVENT sqlserver.query_post_execution_showplan(SET collect_database_name=(1) ACTION(sqlserver.client_app_name,sqlserver.database_id,sqlserver.database_name,sqlserver.query_hash,sqlserver.query_plan_hash,sqlserver.session_id,sqlserver.sql_text) WHERE ([sqlserver].[equal_i_sql_unicode_string]([sqlserver].[session_nt_user],N'FACL-SA-SQL11SRVC') AND [package0].[greater_than_equal_uint64]([cpu_time],(25000000)))), ADD EVENT sqlserver.sql_batch_completed(SET collect_batch_text=(0) ACTION(sqlserver.client_app_name,sqlserver.database_id,sqlserver.database_name,sqlserver.query_hash,sqlserver.query_plan_hash,sqlserver.session_id,sqlserver.sql_text) WHERE ([sqlserver].[equal_i_sql_unicode_string]([sqlserver].[session_nt_user],N'FACL-SA-SQL11SRVC') AND [package0].[greater_than_equal_uint64]([cpu_time],(25000000)))), ADD EVENT sqlserver.sql_statement_completed( ACTION(sqlserver.client_app_name,sqlserver.database_id,sqlserver.database_name,sqlserver.query_hash,sqlserver.query_plan_hash,sqlserver.session_id,sqlserver.sql_text) WHERE ([sqlserver].[equal_i_sql_unicode_string]([sqlserver].[session_nt_user],N'FACL-SA-SQL11SRVC') AND [package0].[greater_than_equal_uint64]([cpu_time],(25000000)))) ADD TARGET package0.event_file(SET filename=N'L:\Data\Hist1\ServiceAccount.xel',max_file_size=(100),max_rollover_files=(10)) WITH (MAX_MEMORY=102400 KB,EVENT_RETENTION_MODE=ALLOW_MULTIPLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=ON,STARTUP_STATE=OFF) GO
Gokhan Varol