Solved

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

Posted on 2007-12-06
5
1,695 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

910 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

20 Experts available now in Live!

Get 1:1 Help Now