SQL Server Script collection

Filed under: sql, sqlserver

This post is a running collection of SQL Server scripts that I have found useful to reference.

Searching for text within stored procedure

SELECT OBJECT_NAME(id)
FROM SYSCOMMENTS
WHERE [text] LIKE '%Foo%'
AND OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY OBJECT_NAME(id)

Change compatibility level in a database

ALTER DATABASE DatabaseName
SET COMPATIBILITY_LEVEL = 120;

Sources

How do I find a stored procedure containing <text>?
View or change the compatibility level of a database

© 2022 JASON RAE