简体   繁体   中英

Why are these strings not equivalent in MySQL but equivalent in SQL Server?

I'm trying to migrate an application database from MySQL to SQL Server using the vendor's conversion tool. When I do, I get a unique constraint violation error that indicates I'm trying to write a value ("Canon Inc.") twice in one column of the SQL Server table.

I logged into the live system (MySQL) and ran the query below, shown with its results (zero records). This tells me that MySQL doesn't see any records where the column contains duplicate values.

屏幕快照显示SoftwareManufacturer表的NAME列中没有重复的值

However, when I search more generally for Canon Inc., I do indeed find two records. But when I check the character & bit lengths of the strings, they're clearly not exactly the same, as shown here:

屏幕截图显示了佳能公司的两条记录,具有不同的位和字符长度

What could the difference be between these two strings? Is there a way for me to clean this up?

My guess would be that you have a trailing space on the second canon inc. That would account for the character length being one more than the other one, and I'd bet that SQL Server is ignoring the trailing space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM