Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 It is possible to search for strings inside VIEWS?

Author  Topic 

lopes_andre
Starting Member

12 Posts

Posted - 2009-12-03 : 14:51:58
Hi,

I have a database with 400 views, and I need to search for a view containing the text "table1".

How can I search for "table1" in 400 views?


Best Regards,

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-12-03 : 15:02:10
select Table_Name from INFORMATION_SCHEMA.Views a
where View_Definition like '%Table1%'


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-04 : 03:02:43
quote:
Originally posted by Vinnie881

select Table_Name from INFORMATION_SCHEMA.Views a
where View_Definition like '%Table1%'


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881


Beware of 4000 charaters limit

The proper way is

1 Generate script of Views to files and do search
ex http://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/13/script-out-procedures-and-functions-part-2.aspx

2 Make use this script

select name from sys.sysobjects
where type='v' and object_definition(object_id(name)) like '%table1%'



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

lopes_andre
Starting Member

12 Posts

Posted - 2009-12-04 : 13:28:28
Thanks, it worked!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-07 : 02:06:49
quote:
Originally posted by lopes_andre

Thanks, it worked!


Which worked?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -