Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Like Operator Exact Match Question
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

danasegarane76
Posting Yak Master

India
242 Posts

Posted - 03/14/2014 :  02:00:02  Show Profile  Send danasegarane76 an ICQ Message  Reply with Quote
Hi Team,
I am using like operator to get some results

And the data looks like

CountryCodes
503:51,880:51,936:51,952

And when I use like

Select * from table where CountryCodes like '%503:5%'
This gets the above set results. But I want to match the exact text .

This means that need to get the result only if
503:5,880:51,936:51,952

Any way to this

nagino
Yak Posting Veteran

Japan
75 Posts

Posted - 03/14/2014 :  02:18:01  Show Profile  Reply with Quote
Like Following ?

Select * from table where CountryCodes like '%503:5,%' or CountryCodes like '%503:5'

-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page

danasegarane76
Posting Yak Master

India
242 Posts

Posted - 03/14/2014 :  02:22:13  Show Profile  Send danasegarane76 an ICQ Message  Reply with Quote
Yes, I tried this and this looks like working with one issue.

I can see the search functionality using a common function where %% append is added globally.

I would like to something like

Select * from table where CountryCodes like '%503:5[\,]%'

where the last , may or may not exist there.

Any way to handle this
Go to Top of Page

nagino
Yak Posting Veteran

Japan
75 Posts

Posted - 03/14/2014 :  02:41:20  Show Profile  Reply with Quote
Select * from table where CountryCodes + ',' like '%503:5,%'

-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000