Search Text in Stored Procedure in SQL Server

Search Text in Stored Procedure in SQL Server

Hello everyone, I am going to share the query for search a text from my all database stored procedures with and without system stored procedures.

#Declare a input text as given below.

DECLARE @SEARCH_TEXT VARCHAR(255)
SET @SEARCH_TEXT=[email protected]'

#Query for Search Text in Stored Procedure without system Procedure

SELECT DISTINCT
      OBJ.NAME AS OBJECT_NAME,
      OBJ.TYPE_DESC
      FROM SYS.SQL_MODULES MOD
              INNER JOIN SYS.OBJECTS OBJ ON MOD.OBJECT_ID = OBJ.OBJECT_ID
              WHERE MOD.DEFINITION LIKE '%'+@SEARCH_TEXT+'%'
              ORDER BY TYPE_DESC

                                                 #OR

#Query for Search Text in Stored Procedure with system Procedure.

SELECT DISTINCT
      OBJ.NAME AS OBJECT_NAME,
      OBJ.TYPE_DESC
      FROM SYS.SQL_MODULES MOD
              INNER JOIN SYS.OBJECTS OBJ ON MOD.OBJECT_ID = OBJ.OBJECT_ID
              WHERE MOD.DEFINITION LIKE '%['+@SEARCH_TEXT+']%'
              ORDER BY TYPE_DESC



ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book