Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2011
    Posts
    10

    Question Unanswered: Type of tel_no with comma “,“ or space or line “-“

    Hi
    What is the type of telephone number with comma between the numbers for easy reading?
    I don’t want to use “char” for this purpose. Can we do it using integer as its type?
    Like 0303-662-2191

    Code:
    CREATE TABLE Tel
    (
    Tel_no int    (I don’t want to use char!)
    );
    INSERT INTO Tel
    (
    0303-662-2191
    );
    Thanks in advance

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    No, you have to use varchar if you want to store a formatted telephone number.

    Actually there is no other datatype suitable to store a phone number.

    Note that char is indeed a bad choice because it is padded to it's length. There is hardly ever a reason to use char over varchar.

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    And in addition, note that a numeric datatype won't work for another reason, as it will not acknowledge leading zeros when entered. (They are dropped.) So, your example of 0303-662-2191, would be stored as 3036622191.

    But, you should be able to strip out non-numeric characters using rules or triggers...
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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