Depreciated SQL 2008 features
I have just come across this useful piece of SQL that shows you how many times you are using depreciated features in your SQL 2008 Database.
Run the SQL on your SQL 2008 database in a new query window to see how many times you are using the depreciated features.
I have just come across this useful piece of SQL that shows you how many times you are using depreciated features in your SQL 2008 Database.
Run the SQL on your SQL 2008 database in a new query window to see how many times you are using the depreciated features.
SELECT *
FROM sys.dm_os_performance_counters
WHERE object_name = 'SQLServer:Deprecated Features'
AND cntr_value > 0;
Whilst these depreciated SQL features still might work in this version of SQL they might not in future releases so fixing them soon is a good idea.
Features that have been depreciated include the often used SET ROWCOUNT N.
For example instead of using SET ROWCOUNT 100 to limit an UPDATE or DELETE statement you would use the new UPDATE TOP(100) or DELETE TOP(100) statements instead.
Whilst the SQL statement for finding out the list of depreciated features is useful it doesn't actually show you where each of the depreciated features are being used in your code.
I don't know if this DMV only looks at stored procs or all queries passed through the system but using a find function like the following piece of SQL might be useful for hunting down depreciated code within the SQL database.
DECLARE @FindStr AS VARCHAR(500)
-- lower case our find string as we lower case the comments
SELECT @FindStr = LOWER('USER_ID')
SET NOCOUNT ON
SELECT DISTINCT NAME AS [NAME],
CASE WHEN TYPE ='P' THEN 'PROCEDURE'
WHEN TYPE IN('FN', 'IF','TF') THEN 'FUNCTION'
END AS OBJECTTYPE
FROM SYSCOMMENTS as comm
JOIN SYSOBJECTS as obj
ON comm.id = obj.id and obj.type IN ('P', 'FN', 'IF', 'TF')
WHERE LOWER(TEXT) LIKE '%' + LTRIM(RTRIM(@FindStr)) + '%'
You can find a list of all the depreciated features in SQL 2008 and ways to fix them on the Technet Microsoft SQL Website.
If anyone knows of any other ways to hunt down the depreciated features within the SQL 2008 database please let me know.
No comments:
Post a Comment