Interview Questions

  • 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

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank You

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply