I have 500 stored procedures in a Sybase database. Using SQL, can I get list of all stored procedures that are using a particular table say tbl_books
?
Using SQL query, we can find out the list of the tables used in the stored procedure, using types of joins like inner join, outer join etc. Using SYSOBJECTS and SYSDEPENDS, we can get all the tables, stored procedure and other database object-related information.
Use something like this:
Select distinct sysobjects.name
, case
when sysobjects.type = 'TR' then 'TRIGGER'
when sysobjects.type = 'P' then 'PROCEDURE'
when sysobjects.type = 'V' then 'VIEW'
else 'UNKNOWN' end type
from sysobjects inner join syscomments
on sysobjects.id = syscomments.id
where syscomments.text like '%tbl_books%'
Initially I'd try sp_depends
.
Syntax: sp_depends objname[, column_name]
For objname
you can supply any object name, for example a table, view or sproc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With