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)
 Pattern Matching

Author  Topic 

ms65g
Constraint Violating Yak Guru

497 Posts

Posted - 2009-10-26 : 11:35:37
Hi,
I want to select rows when 'a' and 'b' and 'c' letters be in the column data string (order and arrangement is not important)
For example:
'cccacb' is true
'abc' is true
'cba' is true
'fabe' is false
Just by one logical expression. I am not looking for this method:

Where Column_Name LIKE '%[a]%'
AND Column_Name LIKE '%[b]%'
AND Column_Name LIKE '%[c]%'

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-10-26 : 11:49:01
Why aren't you looking for that method? Do you have an assignment to use CHARINDEX or some thing else in particular?

Jim



Everyday I learn something that somebody else already knew
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-26 : 11:52:31
your solution is pattern matching

LIKE '[a-cdf]'
you will have to twek it to your need

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -