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
 Sql Query

Author  Topic 

visa123
Yak Posting Veteran

54 Posts

Posted - 2010-12-01 : 08:50:10
Hi

In my table the below multiple values with comma separated

Asset Protection Lead,Corporate 1
Asset Protection Lead Post,Corporate 2
Corporate,Asset Protection Lead 3
Coporate 4
Asset Protection Lead 5

Here i have to retrieve Asset Protection Lead and Corporate.
So i have used the below query.

SELECT * FROM table1
WHERE CONTAINS(field1 ,'"Asset Protection Lead"OR"Corporate"')

So it should retrieve

Asset Protection Lead,Corporate 1
Corporate,Asset Protection Lead 3
Coporate 4
Asset Protection Lead 5

But i am retrieving Asset Protection Lead Post also.

can u please any help me for this issue






Visa.G

Visa.G

Sachin.Nand

2937 Posts

Posted - 2010-12-01 : 08:59:46
Try this

SELECT * FROM table1
WHERE CONTAINS(field1 ,' "*Asset Protection Lead" OR "Corporate"')


PBUH

Go to Top of Page

visa123
Yak Posting Veteran

54 Posts

Posted - 2010-12-01 : 09:03:05
Hi ALL

i got the solution

DECLARE @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
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-12-01 : 09:03:22
Duplicate Post -
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=153611

Please do not repeat the post.

Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

visa123
Yak Posting Veteran

54 Posts

Posted - 2010-12-01 : 09:04:43
ok sure.

Thanks

Visa.G
Go to Top of Page
   

- Advertisement -