• The AND NOT's can get pretty confusing, so just to explain this a bit more:

    The problem is the logic of your where clause. Here's what you're saying(assuming case sensitivity doesn't matter for this explanation):

    WHERE

    [UserName] LIKE '%[^a-z]%' AND

    This will pull in anything with a character other than a-z. So any string with a number passes this test.

    [UserName] LIKE '%[^0-9]%' AND

    This will pull in anything with a character other than 0-9, so anything with a letter passes this test.

    [UserName] LIKE '%[^A-Z]%'

    This will again, pull in anything with a character other than A-Z, so all strings with numbers pass this again.

    Your end result? All strings with a non alphanumeric character(which is what you're after), as well as all strings with both a number and a letter, because these are evaluated separately.

    Combining them like Jack shows above(or with a case sensitive collation using LIKE '%[^a-zA-Z0-9]%' looks for a character outside of *all* of those ranges at once, not each individually, which is what you're trying to do.

    Also, if you were evaluating only a single character, your WHERE clause would be OK, because of the AND's. A single character would never pass all those tests if it was a number or letter, (letters fail the first or third, numbers fail the second, leaving you with what you want), the problem is that you're looking for *any* character in a series that passes for the entire string to pass, so any strings with individual characters that pass each criteria make it through.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]