Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-12-06
5
Medium Priority
?
1,710 Views
Last Modified: 2010-05-18
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
Comment
Question by:yellow1234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 800 total points
ID: 20418422
SELECT VIEW_NAME, VIEW_DEFINITION
    FROM INFORMATION_SCHEMA.VIEWS
    WHERE VIEW_DEFINITION LIKE '%foo%'
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 800 total points
ID: 20418425
sorry, it is TABLE_NAME ...

SELECT TABLE_NAME, VIEW_DEFINITION
    FROM INFORMATION_SCHEMA.VIEWS
    WHERE VIEW_DEFINITION LIKE '%foo%'
0
 
LVL 25

Assisted Solution

by:imitchie
imitchie earned 200 total points
ID: 20418458
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
 

Author Comment

by:yellow1234
ID: 20420878
Thanks guys.
Angelll - that was spot on - imitchi - that was really useful, therefore gave you some points as well.
Thanks again.
0
 

Author Comment

by:yellow1234
ID: 20421366
just
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question