well, in one word wow, thank you so much!
I'm getting ready for an 8 hour flight here, and now I'll definately have
something to do whilst on the plane ;), and yes I am using SQL SERVER
2000, so I'm gonna try it out a little bit here.
Thnx ALOT!
Ewout
> oh....gulp....., well first off thank you very much John for your
insight
i> n all of
t> his....actually the John Smith was a quick sample, there's actually
all
b> usiness names in there, with different names etc. etc. so this sure
l> ooks
l> ike it's going to be a pain....but I'm going to further investigate
and
t> ry
o> ut your suggestions!
> Yours Truly,
> Ewout
>
>>
A> s far as i know, there's no native way in sql server to do it.
However,
i> f you're
r> eturning a recordset to a client application (for example, a VB front
e> nd) - you
c> ould easily use the StrConv function:
> strMyString = "JOHN SMITH"
s> trMyString = StrConv(strMyString, vbProperCase)
> 'strMyString now equal "John Smith".
> however, this will, of course, not work for names like McMuray
(Mcmuray)
o> r Zac de
l> a Rocha (Zac De La Rocha).
> if you wanted to keep the solution in the query, you'd have to break
a> part the
s> tring, by the space character, then UPPER on the first character and
L> OWER on the
r> est. for this, you'd have to run through a loop, if the number of
words
i> n the
f> ields was a varaible.
> But, if it's just the name you're after, if you're lucky - the database
w> ill have
s> eperate columns for the first, last and middle initial, and you could
u> se this:
>
S> ELECT UPPER(SUBSTRING(name_last,1,1)) --capitolize the first letter
> + LOWER(SUBSTRING(name_last,2,LEN(name_last)-1)) --lower the
rest
> + ', ' + --name seperator
> UPPER(SUBSTRING(name_first,1,1)) --capitolize the first letter
> + LOWER(SUBSTRING(name_first,2,LEN(name_first)-1)) --lower the
r> est
> but, if the name is in a single field, already put together, you'll
have
t> o get
t> ricky with the CHARINDEX function to find the Space or Comma
seperating
t> he names
a> nd take those "pieces" and use something similar to what's above to
a> ccomplish what
y> ou're looking for.
> hope that helps and good luck!
> john
> --- nobody knows! nobody knows! <raisorsharp@h...> wrote:
>> Hi there,
>>
>> Does anyone know a query to easily convert all words in a field (that
a> re
>> currently all upper case) to first letter uppercase and then the rest
>> lowercase?
>>
>> ex.
>>
>> JOHN SMITH
>> John Smith <----that's the result I want
>>
>> Ewout
>
=> ====
> ----------------------------
J> ohn Pirkey
M> CSD
h> ttp://www.stlvbug.org
>
_> _________________________________________________
D> o You Yahoo!?
Y> ahoo! Finance - Get real-time stock quotes
h> ttp://finance.yahoo.com