Which data type to use?

  • Here is some sample output:

    2138

    3.28

    55

    28.9

  • DataAnalyst011 (8/16/2012)


    Here is some sample output:

    2138

    3.28

    55

    28.9

    DECIMAL(12,2) ??

  • *blinks* Homework question? I feel like it's being setup for a punchline.

    Books online; data types. Check out int, bigint, decimal, numeric, float, and money, for starters.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Evil Kraig F (8/16/2012)


    *blinks* Homework question? I feel like it's being setup for a punchline.

    Books online; data types. Check out int, bigint, decimal, numeric, float, and money, for starters.

    Personally, stay away from the money and small money data types.

  • Lynn Pettis (8/16/2012)


    Evil Kraig F (8/16/2012)


    *blinks* Homework question? I feel like it's being setup for a punchline.

    Books online; data types. Check out int, bigint, decimal, numeric, float, and money, for starters.

    Personally, stay away from the money and small money data types.

    Well, fair point, I was just being thorough considering the question left me scratching my head as to is this a complete newbie or did I miss some critical gotcha...


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Actually I am a complete newbie. I was hired on at a medical school to create statistical reports and dashboards since I'm basically the only one who knows the business processes. So I've spent hours and hours feeling my way through SQL to try and produce these reports. So far I've written a few thousand lines of working code, but I haven't dealt with creating tables (and therefore data types). It's a real deficiency. Since my learning is on demand it creates weird gaps in my knowledge of both SQL and best practices.

    And I actually did read through the MSDN article on data types and looked at a few other examples, but I simply couldn't get it.

    Either way, thanks for the help, Lynn. You've helped me more than once and I sincerely appreciate it.

    BTW - If anyone has a course/books that would be helpful, I would love to study something more consistency. I really do try and figure things out first before uploading questions!

  • Stairway to Data by Joe Celko[/url]

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • DataAnalyst011 (8/16/2012)


    Actually I am a complete newbie. I was hired on at a medical school to create statistical reports and dashboards since I'm basically the only one who knows the business processes. So I've spent hours and hours feeling my way through SQL to try and produce these reports.

    In a word... ouch.

    So far I've written a few thousand lines of working code, but I haven't dealt with creating tables (and therefore data types). It's a real deficiency. Since my learning is on demand it creates weird gaps in my knowledge of both SQL and best practices.

    BTW - If anyone has a course/books that would be helpful, I would love to study something more consistency. I really do try and figure things out first before uploading questions!

    Gyeah, beginning of my career was no better. I've yet to find a generic, all-inclusive course that walks you through the topics intelligently online. I'd have to recommend picking up one of the 'SQL Server for beginners' Tomes down at the local bookstore... and that reminds me, somewhere around here is that course-layout I was thinking about...

    And I actually did read through the MSDN article on data types and looked at a few other examples, but I simply couldn't get it.

    INT/BigInt: Whole numbers only, small storage.

    Decimal/Numeric: Precision based decimal storage, and the most common usage, and interchangeable. IE: NUMERIC (19,4) means 15 digits on the left, 4 after the decimal. It guarantees precision to that point.

    FLOAT: Can handle both incredibly huge and incredibly tiny numbers... if you don't want guarantees on your precision after the decimal. It's usually necessary when working with incredibly tiny numbers or multiplicative/devisive mathmatics involving decimals.

    Money/SmallMoney: Specifically built NUMERIC values that have a few issues when it comes to things like interest calculations and the like because of enforced decimal allowances.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Hi Craig,

    This is very helpful! I've actually read several things you've posted in the forums, and gained understanding and solutions. Don't worry at all about the first response. Rereading the post I could have set it up a better! It completely looked like a homework question!

    I actually don't know how you guys continue to put up with us newbies. But I think I speak for us all when I say we really appreciate it. Thanks again for the advice. I'll be rereading through your post after my meeting. All the best.

Viewing 9 posts - 1 through 8 (of 8 total)

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