Identifying Deprecated SQL Server Code with Profiler

Problem

In your recent tip (WARNING: SQL Server Deprecated Features) you have outlined a number of deprecated features.  The listing with the mapping to the new code set is beneficial.  Unfortunately I have an enterprise SQL Server environment and I need to be able to identify the deprecated features in more of an automated manner.  We do not have the time to check all of our code (stored procedures, functions, etc.) and I know we have T-SQL embedded in middle tier and front end applications.  How can I analyze this code in an efficient manner?

Solution

In any sized environment, identifying the deprecated SQL Server features could be a long and time consuming process.  Luckily, Microsoft was thinking ahead and has events in Profiler that can be captured to identify the code with deprecated features.  Let’s take a look at how to capture the T-SQL code:




























Launch SQL Server 2005 Profiler

Navigate to Start | All Programs | Microsoft SQL Server 2005 | Performance Tools | SQL Server Profiler.

Profiler InitialScreen 1


 


Start a New Trace

Navigate to File | New Trace… | Authenticate to the SQL Server you want to monitor

Profiler Login 2


 


General Tab – Configurations

Specify the name and configure the results to be saved to a table.

Profiler GeneralTab 3


 


Events Selection Tab – Configurations

In order to review all events, enable the check box for ‘Show all events’ and ‘Show all columns’ on the bottom right of the screen.

Profiler ShowAllEvents 4


Then navigate to the ‘Deprecation’ heading and enable the ‘Deprecation Announcement’ and ‘Deprecation Final Support’ events.


Profiler DeprecationEvents 5


Once you have made these configurations or others as desired, then press the ‘Run’ button to begin the Profiler session.


 


Profiler Results – Deprecated Features

As an example, if you issue this command:

BACKUP TRAN <DatabaseName> WITH NO_LOG
GO


The results in Profiler will be:


Profiler DeprecationExample 6


 


Additional Analysis – Query the Results

SELECT *
FROM <TableName>
WHERE EventClass IN (125, 126);
GO

Next Steps

 

Leave a Reply

Your email address will not be published. Required fields are marked *