Hey everyone,

I'm creating some databases (new to this) and I'd like to specify the maximum number of digits allowed for a record. For example, I have a field for zip code that I would like to limit to 5 digits. Can I do this with any of the binary data types, or should I just use varchar?


Binary (and Varbinary) store binary data in binary format, not digits. I would suggest using Char (or Varchar) types to store zip codes.

Yes, you could use Binary type to store 5 digit numbers from 0 to 99999, but this requires 17 bits. And since Binary type is allocated per bytes you would use Binary(3) eg. 24 bits, not much saving in storage space.

And lastly, you can easily cast digits stored in Char (or Varchar) field back to number with CInt().