[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Checking for alpha characters in a field

Hello All

Is it possible to select items in a SQL field that can only contain letters and nothing else, no numbers, special characters etc.

Many thanks
0
bostonste
Asked:
bostonste
  • 3
  • 3
2 Solutions
 
BrandonGalderisiCommented:
Yup...

This simple example shows how to use patindex to do it.


select 1
where patindex('%[^A-Z]%','aABaC')=0


select 1
where patindex('%[^A-Z]%','aAB1C')=0
0
 
BrandonGalderisiCommented:
just repalce 'aAB1C' or 'aABaC' with your column name.
0
 
Scott PletcherSenior DBACommented:

SELECT column, ...
FROM ...
WHERE column NOT LIKE '%[^a-z]%'
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
Scott PletcherSenior DBACommented:
Yes, I know that's annoying because of the NOT of a not (^), but really, there's no other easy way to do it :-) , at least AFAIK .
0
 
BrandonGalderisiCommented:
That does the same thing.
0
 
Scott PletcherSenior DBACommented:
Except that SQL would consider an index scan on that column for my code, since the column is not imbedded within a function call :-) .
0
 
bostonsteAuthor Commented:
EXCELLENT CHAPS
MANY THANKS
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now