Simran
Simran

Reputation: 569

Full text Search in SQL Server not finding my entries

My requirement is to be able to search imran in Simran, Simrankaur e.t.c

I am using following query:

select Name, Len(Name)
from Demo 
where Contains(Name, '"*imran*"')

My Demo table has Name column with following entries Simran, Simrankaur, SimranKaurKhurana but the query returns nil.

Where am I doing it wrong?

Upvotes: 1

Views: 51

Answers (2)

Dibstar
Dibstar

Reputation: 2364

Try the following if your database is not case sensitive

select Name, Len(Name) from Demo 
where Name like '%imran%'

Note that depending on database settings this may be case sensitive, so this might be more consistent:

select Name, Len(Name) from Demo 
where LOWER(Name) like '%imran%'

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269445

Sounds like you want like:

select Name, Len(Name)
from Demo
where Name like '%imran%';

Even if you use contains, you can't use a wildcard at the beginning of the string.

Upvotes: 2

Related Questions