I have an Excel CSV file with a Barcode
column that has data that looks like this: 5.06E+12
- it has a decimal number(5.06), letter(E) and symbol(+).
When I try to edit this in Excel, the number changes to 5060190000000
.
When storing this type of data to my SQL Server database, what should the data type be of my Model's Barcode
property?
Try to pick the most appropriate data type. If you're using actual product barcodes, a little research indicates that they're likely International Article Numbers.
Since they're really strings of 13 digits, a char(13)
would probably be the most appropriate data type to store this data. Don't just default to varchar(50)
because that's "big enough" - think of the length specification as free validation.
This is called E notation which is a variation of scientific notation. The number in question is an integer, but is abbreviated.
5.06 * 10^12 = 5060190000000
Thus, your value should be stored as an integer large enough to store your number.
Your value should be stored as a varchar long enough to fit the length of potential values.
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