sql >> Base de Datos >  >> RDS >> Sqlserver

¿Cómo encontrar el nombre del procedimiento almacenado, basado en la búsqueda de nombre de tabla, usando SQL Server 2008?

SELECT o.name, o.type_desc, p.name, p.type_desc
FROM sys.sql_dependencies d
INNER JOIN sys.objects o
    ON d.object_id = o.object_id
INNER JOIN sys.objects p
    ON d.referenced_major_id = p.object_id
    AND o.name = 'RejectionReason'

o

SELECT o.name, t.TABLE_NAME, c.text 
  FROM syscomments c 
  JOIN sysobjects o 
    ON c.id = o.id
  JOIN INFORMATION_SCHEMA.Tables t
    ON  c.text LIKE '%RejectionReason%' 

o

EXEC sp_depends @objname = N'RejectionReason';

si ninguno de ellos le ayuda, consulte este blog:object-dependencies-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/">http://blog.sqlauthority.com/2010/02/04/sql-server-get-the-list-of-object- dependencias-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/