views:

25

answers:

1

Hi,

I want to have list of all SPs from my database that fulfill some conditions, say all those SPs that have StudentId in them as i want to update those SPs where StudentId would be a key column.

How can i get the list of all such SPs?

Thanks for your inputs.

+3  A: 
select OBJECT_NAME(object_id) 
from sys.sql_modules
where  OBJECTPROPERTY(object_id,'IsProcedure') = 1 and 
    definition like '%StudentId%' 
Martin Smith
This won't work (i.e., be reliable) if the SP is using a view or UDF that references `StudentId`, though.
RedFilter
@RedFilter - As long as they are not using `*`. It will.
Martin Smith
thanks for inputs.that helped :-)
Romil Nagrani
@Martin: not necessarily - `StudentId` may be used in the `JOIN` or `WHERE` clauses, not in the `SELECT` clause.
RedFilter
@RedFilter - See what you mean. @Romil - You would just remove the `IsProcedure` filter to find those.
Martin Smith