I have a stored procedure, I want to know the name of the tables and views used in this stored procedure, can anyone suggest how I can do this.
Thanks in advance.
You can use sp_depends, but it depends on the current dependency information.
sp_depends
Running sp_refreshsqlmodulefor all objects in the database can update it if there is any dependency information.
sp_refreshsqlmodule
There are several methods
sys.sql_dependencies sp_refreshsqlmodule, , .
select so.name, sc.text from sysobjects so inner join syscomments sc on so.id = sc.id where sc.text like '%ROLES%'-- name of the table
Find the Sp database associated with (using) table XXX