May 1, 2009 at 2:30 pm
Hi -
is it possible to have a constraint on two columns whichs uses "between"?
(if date inserted between DateField1 and DateField2 then fail)
for example, product XYZ's value at $4 starts on 4/1/2009 and ends on 4/30/2009.
product XYZ's value at $5 must start on 5/1/2009, i dont want anyone to enter a record that has an April 2009 date.
thanks!
May 1, 2009 at 2:47 pm
Not sure if that can be done with a constraint. Pretty easy to do with a trigger.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
May 1, 2009 at 2:59 pm
This doesn't look like something you need a constraint for as much as looking at it differently. What you describe fits a design that would use a ValidFrom, ValidTo design, or use effective dates to ensure that the correct Product record is selected based on the date of the order.
May 2, 2009 at 5:27 am
You can create a scalar UDF which gets the ProductId, DateFiel1 and DateField2 and checks if another Product already exists. Then you can use the UDF in your CHECK constraing.
Greets
Flo
May 2, 2009 at 8:39 pm
Florian Reischl (5/2/2009)
You can create a scalar UDF which gets the ProductId, DateFiel1 and DateField2 and checks if another Product already exists. Then you can use the UDF in your CHECK constraing.Greets
Flo
'zactly.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply