Reputation: 2554
Is there any option or any setting by which SQL Server can dump the actual execution plan (at that instance) for stored procs involved in a deadlock?
This is in context of SQL Server 2008.
Upvotes: 3
Views: 1568
Reputation: 300728
Capture the SQL and plan handle and then you might get the query execution plan from the plan cache.
Here's how to capture a deadlock graph before it happens.
Do one of the following:
Select the Save to file check box to capture the trace to a file. Specify a value for Set maximum file size. Optionally, select Enable file rollover and Server processes trace data.
Select the Save to table check box to capture the trace to a database table. Optionally, click Set maximum rows, and specify a value.
Optionally, select the Enable trace stop time check box, and specify a stop date and time.
Select the Events Selection tab. Check Show All Events. In the Events data column, expand the Locks event category, and then select the Deadlock graph check box.
The Events Extraction Settings tab is added to the Trace Properties dialog box.
On the Events Extraction Settings tab, click Save Deadlock XML Events Separately. In the Save As dialog box, enter the name of the file in which to store the deadlock graph events.
Click All Deadlock XML batches in a single file to save all deadlock graph events in a single XML file, or click Each Deadlock XML batch in a distinct file to create a new XML file for each deadlock graph.
After you have saved the deadlock file, you can open the file in SQL Server Management Studio.
Upvotes: 2