Storage Size

  • 4 + 102 + 1 + 4 + 1 + 1 + 202 + 1 = 316

  • As others state: only the NVARCHAR columns already sum up to above the max answer. Therefore, I (wrongly 😉 ) selected the maximum choosable 😉 ...

    [font="Courier New"]
    ------------------------
    MCPD Web Developer, MCPD Windows Developer
    [/font]

    Computers are made to solve problems you did not have in the days they didn't exist.

  • Yes, great question, just not implemented properly.

    I am curious to how the question author missed the length for the nvarchar columns. Or am I missing something?

    If it was easy, everybody would be doing it!;)

  • Since I knew the answer was none of the above before I even bothered to do the calculation, I strongly considered waiting until tomorrow to answer 🙂 However, I couldn't get into this conversation then. Since I didn't save it, I saw a post recently that showed a function that would give the actual rowsize I thought. I can't recall the name of that function, or if that is really what it did. Can anyone remember if there is such a function/procedure?

    **

    DATALENGTH() vs LENGTH() is what I was thinking about.

    **

  • Once I determine that the question (as many ppl have pointed out) didn't know the difference between nvarchar and varchar, I treated those two columns as varchar...Unfortunately, I didn't get the answer correct, because I didn't group the bit columns. So it was a good question.

    I do love the forums, I find them more often more informative than the QoD itself 🙂

  • I thought the QotD was an interesting topic. I would also like to thank Hugo for his in-depth explanation. Points or not, I learned something new.

    Cheers

  • I ended up with the correct-correct data size, and remembered the 2 extra bytes for variable columns, but missed a few of the overhead numbers that Hugo had. Good question, and (Hugo) good answer. Too bad they weren't connected. But it did make me think and did end up pointing out that, even if the correct answer had been presented, I still would have missed it (because of the row-overhead).

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hugo,

    Thanks for the great explanation. It's humbling to know that my best guess wasn't good enough. This knowledge is far more valuable than points.

    Thanks!

  • whats up with the wrong answers to questions lately? This question obviously had NO correct answers. Just simply summing up max_length from sys.columns gives you 316 and that's without adding in the 2 bytes per nvarchar.

    I think everyone should get credit for their answer.

    Someone needs to check these questions before they get posted. This is getting silly.

  • um.....

    nvarchar(n)

    Variable-length Unicode character data of n characters. n must be a value from 1 through 4,000. Storage size, in bytes, is two times the number of characters entered. The data entered can be 0 characters in length. The SQL-92 synonyms for nvarchar are national char varying and national character varying.

    http://msdn2.microsoft.com/en-us/library/aa276823(SQL.80).aspx

    (50 + 100) *2 = 300

    All are invalid

  • Like others, I saw the nvarchar problem but went ahead anyway. The one that threw me was the calculated column not using storage. It's a no-brainer, but mine was on vacation.

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • Hugo Kornelis (4/9/2008)


    Hi all,

    I think this is a great question, though thwarted by an incorrect answer, unfortunately.

    The question is great because hardly anyone knows exactly how this works. That is shown by the fact that of the "correct" answers posted thus far in this thread, none is actually correct. (And boy, do I expose myself to ridicule now should my answer prove to be wrong as well :D)

    But the incorrect answer options result in this QotD being more of a missed opportunity than a learning experience. Sadly.

    So, here are the things that are wrong in either the answer provided as "correct", or in the replies I have seen so far.

    ...

    Wow. Thank you for the detailed follow-up to this Question of the Day. This seems to be a question type that requires even more review than the others - I had some idea that row size is complicated to calculate, but I had no idea it was so involved that even gurus such as yourself might not be 100% confident of the exact answer (you sound 98% confident -- about 90% more than I was 🙂 -- but not 100%). Amazing.

    Thanks again!

    webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • None of the answers are correct.

    PK_ID - 4

    Name - 102

    Profession - 202

    all the bit fields - 1

    DOB - 4

    Total = 313

    nvarchar fields take 2 x the max length + 2 bytes.

  • How is it that so many people can notice all kinds of issues with QOTDs, yet fail to notice their point already previously made in the ensuing discussion thread? Is this a case of selective scrutiny?

    Not just an issue with this thread, of course.....

    Semper in excretia, suus solum profundum variat

  • I think lots of people post their comment without reading. No worries, glad to see them posting 😉

    However I think I'll take a short moratorium on user questions. At least in publishing. We typically have 3-5 weeks scheduled out (doing May now), but I'll move around some of the user questions until I can go through them a bit more carefully.

    I can see how this happened. The user picked a table, was thinking about the bit and computed column values and didn't think through the varchar, much less the "N" values. Actually glanced at it last night and saw "varchar" myself and the quick thumbnail seemed that one of the answers would be right.

    apologies. The question has been changed (and answers) and everyone to this point in time is awarded points.

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

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