Friday, September 10, 2010

Search a table used in SPs

This was asked in a interview. How can you search a table which is used in all the SPs of a database. Very simple, and may be most of you may have used it already.

SELECT '[' + SPECIFIC_CATALOG + '].[' + SPECIFIC_SCHEMA + '].[' + SPECIFIC_NAME + ']', ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%STRING%'

It is a very basic information but makes it easy while making changes to a table name and like to change the procedures using the table.

No comments:

Post a Comment