Monday, September 3, 2007

SQL Server@ List Stored Procedure Names using specific table

Sometimes you need to drop some table or needs to modify the name of the table, and before doing that you want to make sure which are the stored procedures that are using this table?

Secondly, you just want to update the table by deleting it's some column, and you want to make sure which are the stored procedures that are using this column?

The following query gives you the list of Stored procedures that are using some specific table name "CDRMaster".

SELECT Name, create_date,modify_date
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%CDRMaster%'

The following query will give you the list of the stored procedures using some specific column name(CDRID in this case)of the table CDRMaster:

SELECT Name, create_date,modify_date
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%CDRMaster%'
AND OBJECT_DEFINITION(object_id) LIKE '%CDRID%'


No comments: