+ Reply to Thread
Results 1 to 9 of 9

Thread: int vs numeric?

  1. #1
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    int vs numeric?

    Hey All,

    Ok, I believe I've always used int(4) in the past but was curious if I should be using numeric or something else...my values will be a number and most like 4-5 in length. I will need to be able to sum and multiply, etc. with this field...what do you recommend?

    SQL2000

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    Numeric data consists of numbers only. Numeric data includes positive and negative numbers, decimal and fractional numbers, and whole numbers (integers).
    Integer data consists of negative or positive whole numbers.
    In SQL Server, the numeric data type is equivalent to the decimal data type.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    Ok, then I'll stay with int because for the most part it will be positive whole numbers and maybe down the line negative but very unlikely. Its for a headcount of employees in locations, grade, etc.

  4. #4
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    1,040
    Blog Entries
    2
    Rep Power
    13

    Unless you need fractional results, use integer -- numeric/decimal is for exact representation of non-whole numbers. The minimum storage requirement for numeric is 5-bytes, and goes up to 17-bytes and the Precision increases whilst integer is a mere 4-bytes.
    Wolffy
    ------------------------
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

  5. #5
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    no fractions...thank goodness . have you ever used bigint(8)?

  6. #6
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,736
    Blog Entries
    10
    Rep Power
    11

    Quote Originally Posted by Rebelle View Post
    Ok, then I'll stay with int because for the most part it will be positive whole numbers and maybe down the line negative but very unlikely. Its for a headcount of employees in locations, grade, etc.
    Just out of interest, how would you have a negative head count at a location? Did someone lose their head?

  7. #7
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    Quote Originally Posted by richyrich View Post
    Just out of interest, how would you have a negative head count at a location? Did someone lose their head?
    ok..ok...i guess you wouldn't.

  8. #8
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    I will have another field (money) that I will divide by the sum of the field (int)4...

    revenue/sumIntField(s) to display a value in ASP.

  9. #9
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    209
    Rep Power
    4

    I have used bigint, but only for numbers that I expect might exceed the limit of the int datatype (The limit is -2,147,483,648 to 2,147,483,647). Otherwise, int is a much better choice because the amount of storage required is less than a bigint.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO