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.
| Author |
Topic |
|
amirs
Constraint Violating Yak Guru
260 Posts |
Posted - 2009-10-05 : 04:35:36
|
| Dear Memberi have write a select query to search a record to use like keyword of one colomn.in this colom lendth is 10 chari have provide a parameter of searching only two charater in this table mare than 10,00000 records. so the search result is very slow. so any other option to searching a record to replacing 'like' word in queryi have write same like following queryselect * from tabel where col like %'AB'%so plz send any other optiion to search result to same like keywordthanks is advance |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-10-05 : 05:17:23
|
| Try like this..select * from table_name where charindex('as',col_name)>0Put a non-clustered index to the search column if not.Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-10-05 : 12:15:39
|
quote: Originally posted by senthil_nagore Try like this..select * from table_name where charindex('as',col_name)>0Put a non-clustered index to the search column if not.
That is way to do the query without using a LIKE clause. But, that is not going to be any faster than a LIKE clause. Neither can use an index when searching for a text in the middle of text like that. Hence, the poor performance. I don't have much experience with Full Text Indexing, but that might be an option for you..? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2009-10-05 : 12:43:47
|
Please post the DDL with the indexes...If you can lose the leading %, that would helpBut I guess you'll need itDECLARE @t99 table(col1 varchar(10))INSERT INTO @t99(Col1)SELECT 'AB34567890' UNION ALLSELECT '12AB567890' UNION ALLSELECT '12345678AB' UNION ALLSELECT 'XXX4567890' UNION ALLSELECT '12XXX67890' UNION ALLSELECT '1234567XXX'SELECT * FROM @t99 WHERE Col1 LIKE 'AB%' Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|