July 18, 2009 at 11:39 am
Hi, I'm just wonder what is the best way or is it even possible to have a customer error message for a simple check constraint such as.
ALTER TABLE tblJobsCL
ADD CONSTRAINT CK_PlannedEndDate_2
CHECK (PlannedEndDate >= PlannedStartDate)
All the error message handling can I find in my books or online seem to be for triggers.
Thank for your help
Asta
July 18, 2009 at 11:46 am
You can't put a custom error in a check constraint.
Two options.
1) (recommended)
Use a check constraint, have the front end app handle the error and produce whatever custom error that you want
2) use a trigger.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 18, 2009 at 11:50 am
Thanks, glad I asked, saves me looking for something that does not exist.
Asta 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply