all groups > sql server (alternate) > february 2005 >
You're in the

sql server (alternate)

group:

How do I get uppercase values returned only.


How do I get uppercase values returned only. Phillip
2/28/2005 7:10:01 AM
sql server (alternate): I have a table where inactive names are lower case and active names are
uppercase. Note: Not my design.

Anyways I want to select all names form this table where the name is
uppercase. I see collate and ASCII pop up in searches but the examples
don't seem usable in queries as much as they were for creating tables
and such.

Thanks,
Phil
Re: How do I get uppercase values returned only. joeNOSPAM NO[at]SPAM BEA.com
2/28/2005 8:27:02 AM
select * from mytable where name = upper(name)

Joe Weinstein at BEA
Re: How do I get uppercase values returned only. Phillip
2/28/2005 9:55:05 AM
No luck with that

Here is my query
SELECT *, last_nme AS Expr1, first_nme AS Expr2
FROM members
WHERE (last_nme = UPPER(last_nme))
ORDER BY last_nme, first_nme

I still see lower case names.
Re: How do I get uppercase values returned only. Phillip
2/28/2005 9:59:22 AM
I fixed it with this
where ASCII(last_nme) = (ASCII(UPPER(last_nme))

Thanks for the responses.
Phil
Re: How do I get uppercase values returned only. Thomas R. Hummel
2/28/2005 10:52:15 AM
As Phillip found out... this will only work if you have set your
instance of SQL Server set to be case-sensitive. The default
installation makes the instance NOT case-sensitive.

-Tom.
Re: How do I get uppercase values returned only. Erland Sommarskog
2/28/2005 11:04:04 PM
Phillip (pputzback@ECommunity.com) writes:
[quoted text, click to view]

This should do it:

SELECT *, last_nme AS Expr1, first_nme AS Expr2
FROM members
WHERE last_nme COLLATE Finnish_Swedish_CS_AS =
UPPER(last_nme) COLLATE Finnish_Swedish_CS_AS
ORDER BY last_nme, first_nme

You may prefer to use something else than Finnish_Swedish. It's the
CS_AS part that is the important.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button