
Amelia P.
asked 09/02/15Sql doubt regarding datatype
In sql there is a datatype int for integer values and varchar is for either integer or words, so if i want to input like A28 which datatype should i use?
More
1 Expert Answer

David W. answered 09/02/15
Tutor
4.7
(90)
Experienced Prof
Data types store encoded information in very restrictive manners.
For example, integer values of the int data type are converted to binary integer numbers and thus, store only the discrete values allowed in the range of integers with that number of bits. On the other hand, the varchar data type keeps a character string as characters (without converting to binary) and thus takes more bits to represent the data and also allows more variety of input -- spaces, letters, special characters, etc. Of course, performing mathematical operations requires the int data type.
This means that 'A28' (I'm assuming that the 'A' is a letter and that this is not a hexadecimal number with 'A' as a digit) cannot be stored in a variable of the int data type.
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Chandra G.
varchar is for strings and since A28 is an alphanumeric string, you have to varchar. If all strings are of length 3, the type to use is varchar(3)08/23/21