MSSQL search for object usage

mssql

SQL script to search for table or procedure with microsoft sql server

 

 SELECT ROUTINE_NAME, ROUTINE_DEFINITION
    FROM INFORMATION_SCHEMA.ROUTINES 
    WHERE ROUTINE_DEFINITION LIKE '%SBYN_CUSTOMERS_TEMP%' 
    AND ROUTINE_TYPE='PROCEDURE';

 

Or

 


SELECT OBJECT_NAME(id) 
    FROM SYSCOMMENTS 
    WHERE [text] LIKE '%BAR%' 
    AND OBJECTPROPERTY(id, 'IsProcedure') = 1 
    GROUP BY OBJECT_NAME(id);