• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 701
  • Last Modified:

MS SQL-2005 Create Constraint Uniqe

I have a table abc in which two columns a & b. My need is that the a + b column would be unique after Constraint
  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
alter table abc add constraint uq_ab unique (a, b)
MehramAuthor Commented:
Sir the a field is string and b is date

Trailer No       LoadingDate
LSB                 01/01/2007
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now