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)
 Database Wide Search

Author  Topic 

ppsivya
Starting Member

2 Posts

Posted - 2007-09-14 : 16:56:21
Hi,

Is it possible to search for an keyword in the entire database. Is there any such functionality availavble as part of T-SQL or it should be custom code in the application.

Thanks

Kristen
Test

22859 Posts

Posted - 2007-09-14 : 21:56:05
"Is there any such functionality availavble as part of T-SQL"

No. You'll have to write something that searches every column or every table.

I expect that a search of these forums will turn something up, as the topic has been here raised before.

Kristen
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-09-14 : 23:28:09
Following code will generate sql statements to search specific string in all columns of all tables in the db:

declare @searchstring varchar(100)

set @searchstring ='%xxx%'

Select 'Select "'+object_name(id)+'" as tabname,count(*) as RowsMatch from '+object_name(id) + ' where '+name +' like "'+@searchstring +'"'
from syscolumns where xtype in (175,239,99,231,35,167)
Go to Top of Page
   

- Advertisement -