Sunday, January 20, 2019

SQL server find search for Database , Find all stored procedures related tables




Find SP 
sp_helptext 'spname'

Find all stored procedures related tables 
SELECT *  FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%table_name%'

Find all stored procedures newly created
SELECT *  FROM sys.procedures order by create_date desc

Find all stored procedures newly modify
SELECT *  FROM sys.procedures order by modify_date desc

Find all tables 
SELECT * FROM sys.tables

Find table with like
Select * from sys.tables  where name like '%tablename%'



SELECT
    o.name AS ReferencingObject, 
    sd.referenced_entity_name AS ReferencedObject
FROM sys.sql_expression_dependencies  AS sd
INNER JOIN sys.objects AS o
    ON o.object_id = sd.referencing_id
WHERE sd.referenced_entity_name = 'Tabel_Name';



 SELECT name, type   FROM dbo.sysobjects
 WHERE (type = 'P')