Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    51

    Unanswered: validate telephone no.

    i want this column to accept telephone number of this format
    000-000-0000

    what's validation expression do i use? or how can get this db to accept this tel no. format
    i use varchar for data type
    thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I would char...(and I also wouldn't do this)

    Code:
    USE Northwind
    GO
    
    CREATE TABLE myTable99(Col1 char(12) CHECK(Col1 LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'))
    GO
    
    INSERT INTO myTable99(Col1) SELECT '973-555-1212'
    GO
    
    INSERT INTO myTable99(Col1) SELECT '555-1212'
    GO
    
    SELECT * FROM myTable99
    GO
    
    DROP TABLE myTable99
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Gotta agree with Brett. (I usually do...)

    I think you should store the phone number as either unformatted characters (without dashes, spaces, or parenthesis) and format it when output, or store it as simple character string. If you enforce these rules, you are ruling out extensions, international calls, and a plethora of other options.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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