It is not the strange behaviour rather it is default behaviour. An when an intger is converted to varchar, it requires 11 characters for representation. So when you try to insert the integer into varchar it is converted and trimmed the from 11 char converted value to 10 char. the value 1 comes at most right and is trimmed off.
So in order to avoid this truncation, you can either cast the id explicitly to VARCHAR(10). Or use the VARCHAR(11) data type while defining the column.
Hope it helps!
Hi,
It is not the strange behaviour rather it is default behaviour. An when an intger is converted to varchar, it requires 11 characters for representation. So when you try to insert the integer into varchar it is converted and trimmed the from 11 char converted value to 10 char. the value 1 comes at most right and is trimmed off.
So in order to avoid this truncation, you can either cast the id explicitly to VARCHAR(10). Or use the VARCHAR(11) data type while defining the column.
Hope it helps!