April 8, 2011 at 12:03 am
In question i think there should be nchar instead of nvarchar then the answer will be correct
April 8, 2011 at 12:08 am
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.
ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/81ee5637-ee31-4c4d-96d0-56c26a742354.htm
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
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 8, 2011 at 12:10 am
Shocked again :sick: total mismatch between question and answer :exclamationmark:
April 8, 2011 at 12:15 am
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...
April 8, 2011 at 12:16 am
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 🙁
April 8, 2011 at 12:21 am
Wake up and then post a question.
April 8, 2011 at 12:37 am
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.
Sunitha
😎
April 8, 2011 at 12:49 am
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.
Regards,
Lakshmikanth
Project Lead
April 8, 2011 at 1:09 am
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....
😀
April 8, 2011 at 1:27 am
Steve, are you responsible for QoD selections? Shame on you!
Jaap.
April 8, 2011 at 1:48 am
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
April 8, 2011 at 2:05 am
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.
April 8, 2011 at 2:19 am
Good question - pity the answer was given was wrong :-). Alas folks we're not robots and everyone is allowed a mistake...
April 8, 2011 at 2:36 am
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