UPPER and LOWER functions

SELECT UPPER(COLUMN1)
FROM SCHEMA1.TABLE1

SELECT UPPER(COLUMN2)
FROM SCHEMA2.TABLE2

i have 100 records in column 1 and column 2 with roughly half capitol words(HONDA etc.) and rest of half small words(nissan etc.)

when i do UPPER character function

i expected to see 50 records with values like NISSAN


when i do LOWER character function
i expected to see 50 records with values like honda

but i got only 2 records.

can you please advise how to fix this
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
Hi gudii,

Neither the UPPER nor LOWER function should have any impact on the number of rows selected (unless used as part of the filter).

What do you get when you execute

  SELECT column1, UPPER(column1), LOWER(column1) from schema1.table1;
and/or
  SELECT column2, UPPER(column2), LOWER(column2) from schema2.table2;
awking00Information Technology SpecialistCommented:
select column1 from schema1.table1
where column1 = upper(column1);

select column2 from schema2.table2
where column2 = upper(column2);

select column1 from schema1.table1
where column1 = lower(column1);

select column2 from schema2.table2
where column2 = lower(column2);
SujithData ArchitectCommented:
>> but i got only 2 records.
what is the complete query that you are executing?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Mark WillsTopic AdvisorCommented:
And which Database Server ?

And what collation ?

And what datatype ?

Sometimes (depending on the above) you might have to convert to varchar first


e.g.

SELECT UPPER(cast(COLUMN1 as varchar(100))), LOWER(cast(COLUMN1 as varchar(100)))  
FROM SCHEMA1.TABLE1

SELECT UPPER(cast(COLUMN2 as varchar(100))) , LOWER(cast(COLUMN2 as varchar(100)))
FROM SCHEMA2.TABLE2

(And would like to see results if both columns are same case)
awking00Information Technology SpecialistCommented:
Can you provide [some sample] data for columns 1 and 2 in tables schema1.table1 and schema2.table2 and what you expect as output?
slightwv (䄆 Netminder) Commented:
As others have suggested, I can only guess at what you actually mean.

After having read your question about 10 times, I have a slightly different idea about what you are trying to do.

If you want to select only the records what are ALL upper or lower case try this:
select count(*) from SCHEMA1.TABLE1 where upper(column1)=column1;
select count(*) from SCHEMA2.TABLE2 where upper(column2)=column2;
Mark WillsTopic AdvisorCommented:
@slightwv,

in SQL Server you would have to add a case sensitive collation to that clause e.g:

select * from SCHEMA1.TABLE1 where upper(column1)=column1 COLLATE SQL_Latin1_General_Cp1_CS_AS

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.