Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Going_craazy
Starting Member
9 Posts |
Posted - 2008-06-27 : 19:14:51
|
| I am trying to add a check constraint ([IntroDate]>=getdate())for "IntroDate" field. Which has getdate() as default value. I am getting error messages that the constraint is wrong. But if i add a constraint ([IntroDate]<=getdate()), iget no error messages.why doesn't it allow me to check for dates that are on or after todays date. |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-06-27 : 19:37:45
|
what's the error msg exactly? elsasoft.org |
 |
|
|
Going_craazy
Starting Member
9 Posts |
Posted - 2008-06-27 : 22:05:46
|
| I get the following error message'Customer' table- Unable to add constraint 'ValidDate'. The ALTER TABLE statement conflicted with the CHECK constraint "ValidDate". The conflict occurred in database "SQL In 24hrs Book_Activities Practice", table "dbo.Customer", column 'IntroDate'. |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-06-27 : 22:19:23
|
you'll get that error if there is data in the table that violates the constraint you are trying to add.delete or update the offending data and you should be able to add the constraint. elsasoft.org |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-06-27 : 22:25:29
|
or, you could add the constraint WITH NOCHECK. then it won't check the data that's in the table currently but will check on future updates/inserts. elsasoft.org |
 |
|
|
Going_craazy
Starting Member
9 Posts |
Posted - 2008-06-27 : 22:52:11
|
| I added NOCHECK to constraint.For some reason i thought it would only check the current data.Thank you. |
 |
|
|
|
|
|