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)
 stupid like search question

Author  Topic 

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2010-07-13 : 06:11:07
I'm doing this:

where (word like '%' + @word + '%')

which would only give me:
- exact words
- part of words (but not start of word or end of word)

So how could I adapt this, so it will also search for words starting or ending with @word

Would this be the best solution:

where (
(word like '%' + @word)
OR
(word like @word + '%')
OR
(word like '%' + @word + '%')
)

Cause thats seems a bit strange.
Is there anything better.

The secret to creativity is knowing how to hide your sources. (Einstein)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-13 : 06:17:24
word like '%' + @word + '%'
is already giving you what you want because % can be nothing or one or more any characters


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2010-07-13 : 06:31:13
ok, thanks then
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-13 : 07:02:33
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -