In this article, we’ll create a extended event session that collects event information about T-SQL statements which are running more than 10 seconds.
- In
Object Explorer, expand the Extended events then right-click theSessionsfolder and then clickNew Session wizard. Type a name for your session in theSession nametext box. - select Do not use a template.
- select events to capture ( sql_statement_completed, sp_statement_completed)
- capture global fields (sql_text, tsql_stack)
- specify a file name to storage captured data and click next and finish.
- To filter the statements based on duration , right click on the new session -> properties -> events -> click on configure button on right top of the page.
- select the event and specify the filter values (duration > 10000000) and select ok.
- Now right click on new session and select start session then select watch live data to watch the captured sessions.