|  | Posted by gjvdkamp on 07/23/06 17:52 
Q. John Chen schreef:
 > Hello, there,
 >
 >
 > I am trying to find out if a table is used by any of the stored
 > procedures or functions.
 >
 > I can generate all the scripts and look for it. But is there an easy
 > way?
 >
 > THX
 >
 > John
 
 Yep, there is:
 
 CREATE proc [FindInObjects] (@Search varchar(300))
 as
 
 SELECT     so.xtype, so.name, sc.TEXT
 FROM         dbo.syscomments sc RIGHT OUTER JOIN
 dbo.sysobjects so ON sc.id = so.id
 WHERE     so.xtype IN ('P', 'V', 'FN', 'TR') AND (sc.TEXT LIKE '%' +
 @Search + '%')
 
 This will show you a list of all the objects that contain the search
 string.
 
 Enjoy,
 
 GJ
  Navigation: [Reply to this message] |