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 |
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2005-08-21 : 21:58:37
|
| Hi Friendsi've following query to search for a word in a tableselect * from task where Descr LIKE '% myword %' OR Descr LIKE 'myword %'it works nicely but it does not include record that contains carriage return after the word am searching for.I mean it finds first 2 records but not last one1) hi there myword is sql2) myword is sql3)hi there myword ---here carriage return is sqlany idea how to include 3rd record also.ThanksCheers |
|
|
raclede
Posting Yak Master
180 Posts |
Posted - 2005-08-21 : 22:20:23
|
| select * from task where Descr LIKE '%myword%' ---this will do it, just don't include spaces. |
 |
|
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2005-08-21 : 22:30:11
|
| Hi racledebut that may include words including text am searching for.i mean i dont wont following to b included.mywordis ismywordam looking for exact match.hope that makes sense.Cheers |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-22 : 02:19:53
|
| is this?select * from task where Descr LIKE '% myword %' MadhivananFailing to plan is Planning to fail |
 |
|
|
kapilarya
Yak Posting Veteran
86 Posts |
Posted - 2005-08-22 : 03:04:49
|
| try this: copy the condition as it is as last condition has a carriage returnselect * from task where Descr LIKE '% myword %' OR Descr LIKE 'myword %' or Descr LIKE 'myword%'Kapil Arya |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-22 : 03:24:06
|
| kapil, I think this is more effientselect * from task where Descr like '% myword' + char(13)+'%' OR Descr LIKE '% myword %' MadhivananFailing to plan is Planning to fail |
 |
|
|
kapilarya
Yak Posting Veteran
86 Posts |
Posted - 2005-08-22 : 03:29:11
|
| thanka madhivanan, this also works fine and its better.Kapil Arya |
 |
|
|
rajani
Constraint Violating Yak Guru
367 Posts |
Posted - 2005-08-22 : 17:05:26
|
| Thank u very much Kapil Arya and everyone.i got another suggestion from Jeff (sqlcentral.com) which is also cool.SELECT * from task where ' '+Descr+' ' LIKE '% myword %'Cheers |
 |
|
|
|
|
|