Solved

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

Posted on 2007-12-06
5
1,694 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
  • 2
  • 2
5 Comments
 
LVL 142

Assisted Solution

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

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 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 50 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now