Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Search text in SQL stored procedures

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
GO
-----SQL Server 2000
SELECT DISTINCT so.name ,so.xtype
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%myText%'
ORDER BY so.name


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

SELECT DISTINCT o.name 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 (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

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

Working...
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.

Working...

Post a comment on Search text in SQL stored procedures


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer