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 2000 Forums
 SQL Server Development (2000)
 need to check if string contains spaces

Author  Topic 

SQLIsTheDevil
Posting Yak Master

177 Posts

Posted - 2009-03-24 : 10:44:13
I'm trying to formulate a query for checking names. Now, with the dataset with which I'm working, I think that checking if the string contains 2 or 3 words should suffice. Alternatively, I thought why not check how much blank space is there between words. If there's one or two sets of white space, then great.

How may I go about doing this?

I want to try something like '[A-Za-z] [A-Za-z]'. I know that it won't have any numbers, but I am unsure how to specify more than one character in this fashion. I know that regular expressions is not inherently built-in, but there is something like it, what I like to term a lightweight version of it.

Thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-12 : 10:07:39
WHERE Col1 LIKE '%[A-Za-z][A-Za-z]% %[A-Za-z][A-Za-z]%' -- Two words
WHERE Col1 LIKE '%[A-Za-z][A-Za-z]% %[A-Za-z][A-Za-z]% %[A-Za-z][A-Za-z]%' -- Three words


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -