char 列转换为 varchar 仍插入填充
我实在不知道该如何解释这个问题。我已经获取了一个表,创建了它的副本,其中特定列为 varchar 而不是 char。然后我将数据从一张表复制到新表中。但是,当我以编程方式向表中添加新值时,之前为 char(200) 的列仍会填充最多 200 个字符的空间。我尝试过对插入、转换甚至 RTrim(CAST([MynCharColumn] As nVarChar)) 进行强制转换,如在此处的另一个问题中找到的那样,但无论我做什么,该值都会被填充,就好像它是一样仍然是一个字符。
I don't really know how to explain this one. I've taken a table, created 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大胆猜测:如果您使用某种形式的 ORM,ORM 代码可能仍将列作为 char(200) 并将其作为 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?