0

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?

Thanks

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Teme64
0

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().

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.