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 |
|
visa123
Yak Posting Veteran
54 Posts |
Posted - 2010-12-01 : 08:50:10
|
| HiIn my table the below multiple values with comma separatedAsset Protection Lead,Corporate 1Asset Protection Lead Post,Corporate 2Corporate,Asset Protection Lead 3Coporate 4Asset Protection Lead 5Here i have to retrieve Asset Protection Lead and Corporate.So i have used the below query.SELECT * FROM table1WHERE CONTAINS(field1 ,'"Asset Protection Lead"OR"Corporate"')So it should retrieveAsset Protection Lead,Corporate 1Corporate,Asset Protection Lead 3Coporate 4Asset Protection Lead 5But i am retrieving Asset Protection Lead Post also.can u please any help me for this issueVisa.GVisa.G |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-12-01 : 08:59:46
|
Try thisSELECT * FROM table1WHERE CONTAINS(field1 ,' "*Asset Protection Lead" OR "Corporate"') PBUH |
 |
|
|
visa123
Yak Posting Veteran
54 Posts |
Posted - 2010-12-01 : 09:03:05
|
| Hi ALLi got the solutionDECLARE @param NVARCHAR(MAX)SET @param='Asset Protection Lead,Coporate'Select field1 from table1 where (',' + replace(@param, ', ', ',') + ',') like ('%,' + field1 + ',%')This is the method do it.Thanks to all to see this thread!may be help for anyone in future.Visa.G |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
|
|
visa123
Yak Posting Veteran
54 Posts |
Posted - 2010-12-01 : 09:04:43
|
| ok sure.ThanksVisa.G |
 |
|
|
|
|
|
|
|