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 2000 Forums
 SQL Server Development (2000)
 select * from tblMyTable where * like '%findthis%'

Author  Topic 

Beuntje
Starting Member

1 Post

Posted - 2006-02-17 : 09:02:54
I'm searching for the fastest way to find records containing some word.

My table "tblInfo" contains more than 40 columns: id, parentid, treelevel, field1, field2, field3, field4, ... field43, field44, field45
and I want to make a search-QRY to find all records where any of the fields contains "findthis"

Now I'm having the string "select * from tblInfo where field1 like '%findthis%' or field2 like '%findthis%' or field3 like '%findthis%' or ... or field45 like '%findthis%';"

Is there any method to make this QRY shorter (and faster?)

greatings,
Benedikt Beun

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-17 : 09:06:40
Not sure why you have this requirement
See if this helps
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

Madhivanan

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

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-02-17 : 09:36:31
Two other options:

1) Read up on Full Text indexing.

2) You can normalize your tables, then will need to search fewer columns.
Go to Top of Page
   

- Advertisement -