I have a SQL Server database with a time column which can only be filled with the text "am" or "pm" and I'm having trouble finding a constraint that would allow me to do this.
For SQL server you can use CHECK
constraint which allows you to define a predicate that all the rows must meet in order to enter the table. Like so:
ALTER TABLE TableName
ADD CONSTRAINT CHK_ampm
CHECK(ColumnName IN ('am', 'pm'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With