Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    2

    Exclamation Unanswered: Check Constraint

    Hello,
    I am trying to add a check contraint to a column. It will be an ordernum field and it should be in the format YYMMDD-001 ,etc. The data type of the column is char(10).
    Any help would be appreciated.
    Thanks,
    Sean

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Check Constraint

    Try this:
    PHP Code:
      check (translate(ordernum,'0123456789#','##########?') = '######-###'
             
    and substr(ordernum,3,2between '01' and '12'
             
    and substr(ordernum,5,2between '01' and '31'
            

    You would have to add more rules if you wanted to prevent invalid dates like 31st February, but you get the idea?

Posting Permissions

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