char column converted to varchar still inserting padding
I don't really know how to explain this one. I've taken a table, create开发者_开发技巧d a copy of it with a specific column as varchar instead of char. Then I've copied the data from one table into the new one. However, when I then programmatically add a new value to the table, the column that was previously char(200) is still being padded with space up to the 200 characters. I've tried doing a cast on the insert, a convert, and even RTrim(CAST([MynCharColumn] As nVarChar)) as found on another question on here, but no matter what I do the value keeps being padded as if it were still a char.
Wild guess: if you are using some form of ORM the ORM code might still have the column as char(200) and insert it as char. Or, if you are using a stored procedure, did you change the datatype there?
精彩评论