'Storing CHAR(9) in SQL columns
I have a SQL table in which I have a column COLA
of type CHAR(1)
. I am trying to insert CHAR(9)
into this column and I get this error:
String or binary data would be truncated in table
But when I make the column of type CHAR(6)
, it works.
Can anybody tell me why?
Solution 1:[1]
Error - String or binary data would be truncated in table
This error generally occurs, when we try to insert more data into a column than the specified column can store.
In your case you are able to insert CHAR(9) to CHAR(6) maybe because column CHAR(9) has values less than or equal to 6 or white spaces at the end of char are not considered.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AbhishekKhandave-MT |