Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is there a way to search the text of all of my stored procedures for a phrase? For example, all of them that contain a certain TableName?

 

Either built into SQL Server, or with code.

Go Beavs!!!
  • Administrators
Posted

Unless the stored procs have been encrypted the actual text should be visible in the syscomments table. You should be able to query it with something like

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

 

if you are using sql2005 you could also use something like

SELECT Name 
   FROM sys.procedures 
   WHERE OBJECT_DEFINITION(object_id) LIKE '%TableName%'

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • *Experts*
Posted

If you have your procs in a Visual Studio Database project you also have the advantage of doing a search using regular expressions, which can better isolate table names.

 

PD's example is what I generally use when I want a quick check.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...