25112
asked on
constraint to allow past data but enforce new rule from now on?
there is a column in which the data allowed previously was 6 characters. . Now with the new logic, they are expanded to allow 8 characters only. Is there a constraint that can be designed in SQL Server that will CHECK to make sure all new entries from now on will allow and strictly expect 8 characters, but will allow the existing 6 records as is without complaining, but will not allow any new entries with 6 characters?
ASKER
ged325,
if it is a NOCHECK, then even a 9 character or 7 can get in unsuspected, right?
we only want the old records that are 6 in length.. and anything new should be 8 in length (no NULLs)
if it is a NOCHECK, then even a 9 character or 7 can get in unsuspected, right?
we only want the old records that are 6 in length.. and anything new should be 8 in length (no NULLs)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i got it now.. thanks ged325!
ADD CONSTRAINT [LengthConstraint] CHECK (DATALENGTH([your_column])