Search for text in stored procedures - 2000 - 2005 - 2008 - 2012

20 March,2007 by Tom Collins

Search for text in stored procedures is useful, a typical example is object renaming\remapping.

There is one example for SQL Server 2000 and two examples for SQL Server 2005 - 2008 - 2012

USE MyDatabase
-----SQL Server 2000
FROM syscomments sc
INNER JOIN sysobjects so ON
WHERE sc.TEXT LIKE '%myText%'

-----SQL Server 2005 - 2008 - 2012

SELECT DISTINCT AS Object_Name,o.type_desc
FROM sys.sql_modules m 
INNER JOIN sys.objects o 
ON m.object_id=o.object_id
WHERE m.definition LIKE '%some_text%'
AND o.type='P'

 Related Posts

Stored Procedure Checklist

SQL Stored Procedure Commenting

Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on Search for text in stored procedures - 2000 - 2005 - 2008 - 2012 | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer