Recentemente precisei de todas as tabelas em uma procedure no SQL Server. Buscando em alguns arquivos guardados encontrei alguns scripts que mostram exatamente isso.
Abaixo vou colocar-los, fiz alguns testes eles não funcionam caso a tabela esteja em um outro banco de dados ou outro servidor, ou seja, funciona para as tabelas no banco de dados local que está consultando.
;WITH stored_procedures AS (SELECT o.name AS NomeDaProcedure, oo.name AS NomeDaTabela, ROW_NUMBER() OVER (PARTITION BY o.name, oo.name ORDER BY o.name, oo.name) AS row FROM sysdepends d INNER JOIN sysobjects o ON o.id = d.id INNER JOIN sysobjects oo ON oo.id = d.depid WHERE o.xtype = 'P') SELECT NomeDaProcedure, NomeDaTabela FROM stored_procedures WHERE row = 1 /*Caso queira filtrar por nome da procedure*/ --AND NomeDaProcedure = '' ORDER BY NomeDaProcedure, NomeDaTabela
SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id = so.id WHERE sc.TEXT LIKE '%NomeDaTabela%' -- Segunda opção: SELECT DISTINCT o.name, o.xtype FROM syscomments c INNER JOIN sysobjects o ON c.id = o.id WHERE c.TEXT LIKE '%NomeDaTabela%'
Apreciem
Blackjack, additionally known as twenty-one, is just one of one of the most popular gambling…
If you are a fan of online gambling, then you must have come across gry…
On the internet online casinos have transformed the betting industry, enabling players to vegas.hu online…
Casinos online offer free spins to draw new customers. These bonuses are usually very profitable,…
In recent times, online casino sites have actually obtained enormous appeal among gamers, providing a…
Bitcoin, the most preferred cryptocurrency worldwide, has reinvented lots of industries, including the on baixar…