Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Como encontrar o nome do procedimento armazenado, com base na pesquisa do nome da tabela, usando o 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'

ou
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%' 

ou
EXEC sp_depends @objname = N'RejectionReason';

se nada disso ajudar você, verifique este blog:http://blog.sqlauthority.com/2010/02/04/sql-server-get-the-list-of-object- dependencies-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/