Situatie
Mai jos este o procedura ce primeste ca parametu numele unei proceduri sql de pe server si, pentru acea procedura, returneaza toate tabelele ce sunt utilizate in codul procedurii, precum si id-ul aferent fiecarei tabele utilizate.
Solutie
create procedure TablesInASpecificStoredProcedure_prc
@StoredProcedureName varchar(max)
as
SELECT DISTINCT
o.id, o.name as ‘Procedure_Name’ , oo.name as ‘Table_Name’, d.depid as TableId
FROM sysdepends d, sysobjects o, sysobjects oo
WHERE o.id=d.id
and o.name= @StoredProcedureName
and oo.id=d.depid and depnumber=1
ORDER BY o.name,oo.name
Leave A Comment?