MS SQL-2005 Create Constraint Uniqe

Posted on 2007-10-10
Last Modified: 2008-06-24
I have a table abc in which two columns a & b. My need is that the a + b column would be unique after Constraint
Question by:Mehram
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    alter table abc add constraint uq_ab unique (a, b)

    Author Comment

    Sir the a field is string and b is date

    Trailer No       LoadingDate
    LSB                 01/01/2007
    LVL 142

    Accepted Solution

    the unique constraint can be build on such field indeed.
    now, if the LoadingDate field also has been filled with time, you have 2 options:
    * ensure the field is NOT loaded with time portion
    * add a computed field to your table, getting the date portion only, and include that field in the unique constraint instead of the original field.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
    So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now