I want to alter the type of a column from bit to tinyint. This is my SQL:
ALTER TABLE table ALTER COLUMN column TINYINT NOT NULL
This tells me that there is a constraint for column. I dropped the constraint, but is this really necessary? Whats the right way to do this? I think afterwards I need a constraint, too.
Thanks 🙂
Yes this was necessary.
A constraint on a
BITfield can’t possibly work on atinyintfield since they are different datatypes.The
BITvalue of1doesn’t mean “The number one”, it indicatestrueoryesoron.It’s as if you had a rule:
…and then you changed the value to be a decimal datatype. The decimal can’t possibly meet the criteria of the constraint.
Before DDL operations you must disable constraints since they may be invalid after the change.