views:

40

answers:

3

Hi All,

I have a stored procedure, I want to know the name of the tables and views use in that stored procedure, can any one suggest how can I do so.

Thanks in advance.

+4  A: 

You can use sp_depends but this depends on the dependency information being up to date.

Running sp_refreshsqlmodule on all objects in the database can update this if there is any missing dependency information.

Martin Smith
Sorry for the edit - I thought this was my answer, and was trying to add a link ;-)
Cade Roux
@Cade - Thanks for the edit. Edit Ha Ha Feel free to either leave it in or take it out as you wish!
Martin Smith
+1  A: 
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 Sp form database which is related to(using) table XXX

Pranay Rana