May 20, 2005 at 10:35 am
Has anyone out there got a script I can run against a database to list all the views called BY a stored procedure.
I need a list like
sp1 - view85
sp1 - view96
sp2 - view786
....etc
May 20, 2005 at 12:54 pm
the text for an sp , if not encrypted, can be searched in syscomments.
select sysobjects.name from sysobjects
inner join syscomments on sysobjects.id = syscomments.id
where sysobjects.xtype='P'
and text like '%view%'
Lowell
May 20, 2005 at 1:46 pm
select ROUTINE_NAME, VName
from INFORMATION_SCHEMA.ROUTINES
cross join
( select TABLE_NAME as VName
from INFORMATION_SCHEMA.TABLES
where TABLE_TYPE = 'VIEW'
and OBJECTPROPERTY(OBJECT_ID(TABLE_NAME),'IsMSShipped') = 0 ) v where patindex ( '%'+Vname+'%', ROUTINE_DEFINITION) > 0
Enjoy
* Noel
May 23, 2005 at 2:32 am
Thank you both. You have saved me a mammoth task. I will have to tell my manager that I won't need need the budgeted amount of time to complete the job. Or will I?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply