[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • 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
0
Mehram
Asked:
Mehram
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
alter table abc add constraint uq_ab unique (a, b)
0
 
MehramAuthor Commented:
Sir the a field is string and b is date

Trailer No       LoadingDate
LSB                 01/01/2007
0
 
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.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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