August 5, 2012 at 10:31 pm
Hi ,
Suppose i have 100 stored procedures. Now i want to search for 'abc' in all the 100 Stored Procedure. How can i perform that task.
August 6, 2012 at 12:18 am
use <database>
go
select * from sys.sql_modules
where definition like '%abc%'
August 6, 2012 at 12:32 am
Try with the following
Use "Your-DBNAME"
GO
SELECT DISTINCT o.name ,o.xtype
FROM syscomments c
INNER JOIN sysobjects o ON c.id=o.id and o.type='p'
WHERE c.TEXT LIKE '%SEARCH_TEXT%'
PS: type='p' is to retrieve only stored procedures from sysobjects.
Thanks
Kivan 😉
August 6, 2012 at 5:07 am
You can create a script of all stored procedures in a database & search through that. It's easy to see the context & skip from one proc to another.
If you start somewhere new it can be a handy way of finding how/where particular tables & functions are used.
Right-click on the database, select Tasks, select Generate Scripts - then choose all procedures.
August 6, 2012 at 5:09 am
Download Redgate's free SQL Search product & use that - it's very intuitive.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply