Monday, October 21, 2013

Overview of the latest deadlocks on your SQL Server as of SQL 2008



In case you want to analyze the deadlocks which occur on your server, you can use the information from the SYSTEM_HELATH session.
Use next query to retrieve the latest deadlock information.
SELECT CAST(event_data.value('(event/data/value)[1]',
'varchar(max)') AS XML) AS DeadlockGraphFROM ( SELECT XEvent.query('.') AS event_data
FROM ( -- Cast the target_data to XML
SELECT CAST(target_data AS XML) AS TargetData
FROM sys.dm_xe_session_targets st
JOIN sys.dm_xe_sessions s
ON s.address = st.event_session_address
WHERE name = 'system_health'
AND target_name = 'ring_buffer'
) AS Data -- Split out the Event Nodes
CROSS APPLY TargetData.nodes('RingBufferTarget/
event[@name="xml_deadlock_report"]'
)
AS XEventData ( XEvent )
)
AS tab ( event_data )
 
Be aware that, due to changes in the deadlock graph to support multi-victim deadlocks, and to minimize the size of the event data, the resulting XML cannot be saved as an XDL file for graphical representation.
More information about analyzing deadlocks can be found here

Friday, July 19, 2013

Reference parameter values in a text box without parameter fields.


You can add the parameter value of a parameter to a text field in you report but after adding you get next content in the text box:

[ERVCountries].[Country].&[Netherlands]

You only want to have: Netherlands

Solution: Change the reference expression to use .Label instead of .Value.
In this example use:

=Parameters!ERVCountriesCountry.Label(0)

To display multiple parameter values you an use next syntax:

="My own text: " + Join(Parameters!Country.Label,", ")
For more details about displaying multi value parameters click here for a more detailed blog post

Tuesday, July 16, 2013

The selected Subscriber does not satisfy the minimum version compatibility level of the selected publication


The error message as mentioned in the title: 'The selected Subscriber does not satisfy the minimum version compatibility level of the selected publication' , can occur when you are setting up a subscription from a SQL 2008 R2 publisher to a SQL 2012 subscriber using SQL Server Management Studio (SSMS) version of SQL 2008 R2.
This error is caused by SSMS.

Solution:
Use the SSMS version of SQL 2012, now you are able to setup the Subscription from a SQL2008 R2 publisher to a SQL 2012 subscription.

TSQL statement of running queries

In a SQL production environment it can happen that you see heavy transactions. With next query you can retrieve the TSQL statement of a process you see in master..sysprocesses.

SELECT Text,hostname, program_name, nt_username,*
FROM Master..sysprocesses
CROSS APPLY sys.dm_exec_sql_text (sql_handle)
WHERE Spid > 50


You can extend the WHERE clause with SPID = XX or something else you wnat to filter on.