• In question i think there should be nchar instead of nvarchar then the answer will be correct

  • mohammed moinudheen (4/7/2011)

    Books online reference below.

    nvarchar [ ( n | max ) ]

    Variable-length Unicode character data. n can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for nvarchar are national char varying and national character varying.


    Answer should be 6.

    The correct answer is 4 - run the code.

    Jason...AKA CirqueDeSQLeil
    I have given a name to my pain...MCM SQL Server, MVP
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Shocked again :sick: total mismatch between question and answer :exclamationmark:

  • Ho-Hum Question about one topic, answer about another.... Explains why i got it "wrong" Seems to me however, that it is the published answer that is wrong for the question....

    we wait and see...

  • Agreed, either the question should be changed to use NCHAR or the answer should be updated to correctly be 4. We're CS people, accuracy and correctness is important in our lives! 😉 I'm sure I'm not the only one irked by the fact that the question is blatantly broken (see what I did there, that alliteration? Awesome eh?).

    The answer is definitely not 6, it must be a result of the DATALENGTH() function not of DB storage.

    Since I posted my answer another 50+ people have all answered and suffered through it 🙁

  • Wake up and then post a question.

  • Answer is completly Wrong

    declare @a nvarchar(30)

    set @a='aa'

    select datalength(@a)

    Answer as per sql server is 4

  • I too have answered it as '4',but the answer is based on nchar(30) whereas the question is for nvarchar(30).This is really unfair to all those who answered '4' instead of '60'.

    Thinking is the hardest work there is, which is the probable reason so few engage in it.


  • For your code shown below I totally disagree with your answer

    declare @a nvarchar(30) -- See the Difference

    set @a='aa'

    select datalength(@a)

    Explanation: u have declared Variable-length Unicode character data and the answer for your above code is 4

    Justification: The storage size, in bytes, is two times the number of characters entered + 2 bytes -- for nvarchar

    If you have posted the code as shown below then your answer is correct and I Agree.

    declare @a nchar(30) -- See the Difference

    set @a='aa'

    select datalength(@a)

    Explanation: If you have declared Fixed-length Unicode character data of n characters then the answer is 60 and you are correct

    Justification: The storage size is two times n bytes -- for nchar.

    Conclusion: My Answer is Correct

    Advice: Before you post this type of question(s), I would Advice you to verify the answer twice or thrice.



    Project Lead

  • Question and answer don't match up, I answered 4 based on the question to only find out that I was wrong but sure that I was right. Entering the forum I see I am not the only one that got it wrong.

    Can I get my point now please....


  • Steve, are you responsible for QoD selections? Shame on you!


    If you cant do things the way they must be done, do them the way you can ...

  • Like most others I would say 4 - surprised at what the answer "should" have been.

    Ran the code against different servers 2005, 2008 , 2008 R2 (in case that made a difference) and got

    4 every time.

    set childish_tanrum on

    want my points!

    set childish_tanrum off

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • I'm take aback by the fact this question made it on to the site.

    Come on Steve, you seem to be letting any Tom, Dick and Harry set questions.

  • Good question - pity the answer was given was wrong :-). Alas folks we're not robots and everyone is allowed a mistake...

  • This was removed by the editor as SPAM

Viewing 15 posts - 16 through 30 (of 138 total)

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