Skip to content
Advertisement

Check the number of digits or their range

I tried to create a table for save Tradeshows and I need to save Year and Month into different columns.

I have a problem with my back-end and front-end developers for check data. I need to check years is 4 number and month between 1-12. Speed is important to me.

Advertisement

Answer

Just use check constraints:

Or, you could get fancy and validate that the two together form a valid date:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement