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
 General SQL Server Forums
 New to SQL Server Programming
 Option of LIKE Keyword

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2009-10-05 : 04:35:36
Dear Member
i have write a select query to search a record to use like keyword of one colomn.in this colom lendth is 10 char
i 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 query
i have write same like following query
select * from tabel where col like %'AB'%


so plz send any other optiion to search result to same like keyword


thanks 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)>0

Put a non-clustered index to the search column if not.

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

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)>0

Put 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..?

Go to Top of Page

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 help

But I guess you'll need it


DECLARE @t99 table(col1 varchar(10))

INSERT INTO @t99(Col1)
SELECT 'AB34567890' UNION ALL
SELECT '12AB567890' UNION ALL
SELECT '12345678AB' UNION ALL
SELECT 'XXX4567890' UNION ALL
SELECT '12XXX67890' UNION ALL
SELECT '1234567XXX'


SELECT * FROM @t99 WHERE Col1 LIKE 'AB%'






Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -