Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 The Yak Corral
 Search for text in Stored Procedure

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2004-02-05 : 08:20:56
I've seen several threads about how to search stored proceduress for specific text. The best solutions always seem to rely on Windows "Search", which never worked for me.

I ran accross [url]http://dougknox.com[/url] for unrelated reasons and noticed on the page

WINDOWS XP Fixes - the last link "Windows XP Search problems" , has a fix for "Can't find files containing text"

While he offers a download to add any file extenion (like .SQL) to the text search, I followed his tip on "how to modify the registry".

quote:
Windows® XP has a known issue for not finding a number of File Types when you do a Search for Files "containing text" or using the "A word or phrase in the file" option. This can be remedied for many file types, but not all. The cause is the lack of a PersistentHandler value in the Registry for this type of file.

You can correct this by clicking Start, Run and entering REGEDIT Navigate to HKEY_CLASSES_ROOT and locating the entry for the file type in question. For example, .txt, .adm, .asp. Expand the branch for that file type, and if the PersistentHandler subkey does not exist, create it. Do this by clicking on the file extension key and going to Edit, New, Key. Name the Key, PersistentHandler. Click on the PersistentHandler sub-key. In Regedit's right pane, double click on the Default value and enter the following (copy and paste may be your best bet):

{5e941d80-bf96-11cd-b579-08002b30bfeb}

If the PersistentHandler sub-key does exist, do not change the default value. This could have very undesired consequences.


Nice to be able to search Stored Proces for text.

Sam

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-02-05 : 08:27:25
Or, drop into a command line and type :

find /I "searchstring" *.sql

(/I is for ignore case)



Damian
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2004-02-05 : 08:42:37
I know you're being helpful, pointing out workarounds. I'm reminded of Fred Flintstone's automobile when I think of using a command line for text searching in Win XP.

What kind of car do you drive and how are the floorboards?
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-02-05 : 08:56:42
I'm serious! Command line rocks.
I have a command line open pretty much all the time now. I also have either Cygwin or a GNU Utils port, depending on which machine I'm on so I can use "grep" which is a little faster with a nicer output.

I can mkdir a hell of a lot faster than it takes to right click / new folder / rename.
I can "type *.sql > all.sql" to concatenate a directory of sql files for running.

There are a stack of .NET tools that use command line, in fact someone just released an addin for VS.NET to have a dockable commandline inside the IDE.
Also, MS are developing a new powerful command shell in Longhorn based on customer feedback.

It's coming back with a vengance Sam


Damian
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2004-02-05 : 09:03:07
It's like "Night of the DOS"

Graz. We need a survey: Users who would rather fight than use a command line....
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-02-05 : 09:10:50
heh
Rob and I against the world!


Damian
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2004-02-05 : 09:19:19
I was incorrect. It's actually

Night of the living DOS

I'll bet Brett, Tara and many other SQLTeam'ers are right in there with the

command>dothisobscurenit -r -w -t

If I don't have a GUI I try to avoid it completely. (Isn't SQL a command line language?) I'm surprised I edited the registry to fix this problem. I usually avoid regedit like the plague (and it's a quasi-gui)

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-02-05 : 10:49:38
Oh, Sammy...

What do you think QA is?

Forget the GUI

Ever use master..xpcmdshell?

How about...

master..xp_cmdshell 'ECHO ''Starting sproc process 1'' > c:\sproc.log'

As far as searching sprocs...I've used to script them, load to a 1 column table and the use sql...

You could take it further...

script every sproc in to a single file...interogate the directory where they are all stored...save it to a table variable, use dynamic sql to bcp in every file, along with it's file(sproc) name...then use sql to interogate the sprocs...

MOO



Brett

8-)
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2004-02-05 : 10:56:23
Sick. There's help for this problem.

Ever consider the future for websites that offer psychological counseling? Skip the office visit, just go to our home page..

The doctor is IN. Enter your problem here:

We accept VISA, Mastercard, Discover

They're probably already out there. I've never looked.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-02-05 : 14:17:58
quote:
Originally posted by SamC

Sick. There's help for this problem.

Ever consider the future for websites that offer psychological counseling? Skip the office visit, just go to our home page..

The doctor is IN. Enter your problem here:

We accept VISA, Mastercard, Discover

They're probably already out there. I've never looked.



I'll give you sick...


have fun

http://weblogs.sqlteam.com/brettk/




Brett

8-)
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-02-05 : 19:42:10
Sam-

http://weblogs.sqlteam.com/robv/archive/2003/09/28/181.aspx

If you can find a way to import an entire directory of files into a database, using ONE LINE OF CODE, then you can complain about command line utilities.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-02-05 : 19:48:36
I put this link in Brett's feedback, but in case some people don't make it to the feedback section:

http://vyaskn.tripod.com/code/search_stored_procedure_code.txt

With the above utility (stored procedure), you can search stored procedures, UDFs, and triggers for a given keyword.

Tara
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-02-05 : 20:09:48
Just to add fuel to the fire:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=32319

I've been using it for a few months, nothing fancy, but it does the trick. I did deliberately name it sp_ and put it into master, for convenience sake.
Go to Top of Page
   

- Advertisement -