Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get number of words in a sql server field
Message
De
11/10/2007 09:20:57
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01260240
Message ID:
01260251
Vues:
15
Nice Sergey. There is always a possibility that typos could be in there like for a lastname field:

2illiams ,
Smith.Holmes (instead of Smith-Holmes)
Sm1th Jones (this would work fine in the first resolution)

Not sure how to check for typos, guess those will have to be dealt with manually. The goal is to pull all records with more than one word in the field and then figure out how to break it up to where it needs to go into separate fields.

>More generic way
>
>DECLARE @Delimiters varchar(10)
>SET @Delimiters = ' ,'
>IF PATINDEX('%[' + @Delimiters + ']%', LTRIM(RTRIM(mycolumn))) > 0
>
>>Thanks Sergey, I'll try it!
>>
>>
>>>>I would like to determine the number of words in a field in a sql server table. Is there an easy way to do it? I really just need to know if there is more than one word in a field.
>>>
>>>Tracy,
>>>
>>>Assuming that words are separated by spaces and there are no leading spaces
>>>
>>>LEN(mycolumn) <> LEN(REPLACE(mycolumn, SPACE(1), SPACE(0)))
>>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform