April 22, 2013 at 9:54 am
Hi
I am facing following interview questions. table i am having one column .That column records like following
SATHEESH
KUMAR
ARUN
rahul
sURYA
Selvi
Now i want following results.whever i am using lower case letter.please help me
rahul
sURYA
Selvi
April 22, 2013 at 10:09 am
this interview question is testing to see if you know about collation.
there are UPPER and LOWER functions for converting things;
the problem is unless you explicitly state the collation, a default collation of case insensitive is probably going to be used.
That means, as far as SQL server is concerned, 'rahul' = 'RAHUL' unless you test it with a collation.
my example below demonstrates a match for anything that is 100% lower case.
your test would be the opposite...you want anything that is not 100% upper case, and i leave it to you to modify and test my example so you can understand the concept completely.
With MyCTE (vname)
AS
(
SELECT 'SATHEESH' UNION ALL
SELECT 'KUMAR' UNION ALL
SELECT 'ARUN' UNION ALL
SELECT 'rahul' UNION ALL
SELECT 'sURYA' UNION ALL
SELECT 'Selvi'
)
SELECT *,
CASE
WHEN vname = LOWER(vname) COLLATE Latin1_General_BIN
THEN 'Is LowerCase Match'
ELSE 'Not A Match'
END
FROM MyCTE
Lowell
April 22, 2013 at 10:14 am
Thank You
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply