Finding Deprecated Command Usage via Traces and Extended Events

Below is my posting on dealing with upgrading your SQL Server to either 2012 or 2014 and having to deal with databases that are still running under a compatibility mode of 2005. The links below show the deprecated commands with each new version:

Deprecated Database Engine Features in SQL Server 2012
Deprecated Database Engine Features in SQL Server 2014

Here is a link to set up a trace:
Identify deprecated SQL Server code with a server side trace

Compatibility Level

The compatibility level of a database dictates how certain language elements of the database function as it relates to an earlier version of SQL Server. In a nutshell, this offers up partial “backward compatibility” to an earlier version. This functionality isn’t all encompassing as only certain aspects (i.e. certain syntax) of the database would pertain to this setting. For more details as to what is or isn’t affected, check out Books Online.

We know from various online sources that these are the following compatibility levels:

SQL Server 6.0 – 60
SQL Server 6.5 – 65
SQL Server 7.0 – 70
SQL Server 2000 – 80
SQL Server 2005 – 90
SQL Server 2008 – 100
SQL Server 2012 – 110
SQL Server 2014 – 120
SQL Server 2016 – 130

It’s also worth noting that the compatibility level is only available for 3 previous (including the one that you are on) versions from the current version of SQL Server that you are working with. Here is a listing of the available compatibility levels:

Compatibility Levels
Version, Current Compatibility Level, Oldest Available Level
SQL 2016, 130 110
SQL 2014, 120, 100
SQL 2012, 110, 90
SQL 2008, 100, 80
SQL 2005, 90,

You can find out the compatibility level of a specific database bu running the following query:

Deprecated Commands Query

Here is a short query that will provide all counters of deprecated commands for your specific version fo SQL Server. For example if you are running SQL Server 2012 the query provided will show all deprecated commands for the version lower than the one that the query ran against.

Here is the query:

Here are some typical results:

DeprecatedCommandsDMV

Below is the script found on this site on how to identify deprecated commands via Extended Events:
Identify Deprecated SQL Server Code with Extended Events

Here is the Extended Events script:

Views – 2464