Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: Using Int in tables

    I have built a table and one of the fields uses int as the data type.

    When I come to write data to it, I get a problem of that I have to many digits for the size of the field.

    I am trying to input a IDNumber which has 10 numbers. the wierd thing is that I created the table by taking fields that are already made in other tables and it works ok in there, where could I have gone wrong?
    Last edited by JezLisle; 11-07-08 at 10:21. Reason: Ignore this as me being a dope ;-)

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    depends on which 10 digits

    if the leading digit is greater than 3, you're in trouble
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    this is example of what a number would be like
    474648144

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    Use BIGINT for these fields. As r937 pointed out, INT datatypes top out at just over 2 billion.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use VARCHAR

    if you're not going to perform math--AVG(IDnumber) perhaps?--then don't use an integer type
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Feb 2007
    Posts
    62
    Quote Originally Posted by r937
    use VARCHAR

    if you're not going to perform math--AVG(IDnumber) perhaps?--then don't use an integer type

    ...Or treat it as a number for comparisons, or join against another int column, or ...... Strange advice. If it really is a number (as opposed to an account number/serial number etc) then do not treat it as a varchar. That way lies madness.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by LoztInSpace
    (as opposed to an account number/serial number etc)
    it's an IDNumber

    you could look that up
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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