• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1720
  • Last Modified:

How to find / list all views with specific string (SQL 2005)

How to find / list all views with specific string?

I found the equivalent for the stored procedure:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
    FROM INFORMATION_SCHEMA.ROUTINES
    WHERE ROUTINE_DEFINITION LIKE '%foo%'


This is exactly what I am looking for but this only shows procedures... I want to have a list of the views...

Thank you
0
yellow1234
Asked:
yellow1234
  • 2
  • 2
3 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
SELECT VIEW_NAME, VIEW_DEFINITION
    FROM INFORMATION_SCHEMA.VIEWS
    WHERE VIEW_DEFINITION LIKE '%foo%'
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry, it is TABLE_NAME ...

SELECT TABLE_NAME, VIEW_DEFINITION
    FROM INFORMATION_SCHEMA.VIEWS
    WHERE VIEW_DEFINITION LIKE '%foo%'
0
 
imitchieCommented:
You can query Views and Procedures at the same time

select distinct object_name(o.id) as [Name], case o.xtype
 when 'P' then 'Procedure'
 when 'FN' then 'Scalar function'
 when 'IF' then 'Inline function'
 when 'TF' then 'Table valued function'
 when 'V' then 'View'
 end as [Object Type]
from syscomments i
 inner join sysobjects o on o.id = i.id
where o.xtype in ('P','FN','IF','TF','V')
 and text like '%foo%'
0
 
yellow1234Author Commented:
Thanks guys.
Angelll - that was spot on - imitchi - that was really useful, therefore gave you some points as well.
Thanks again.
0
 
yellow1234Author Commented:
just
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now