简体   繁体   中英

RTRIM working with SELECT but not with UPDATE

I've moved a database from DB2 to SQL Server 2016 using Microsoft's Migration tool. Many of my source tables in DB2 are the CHARACTER data type and it maps to a CHAR in SQL Server. Once the tables are moved over I'm getting trailing spaces in my SQL Server tables. Using a SELECT I can remove them in query results using LTRIM(RTRIM(column)), but if I use

 UPDATE table SET column = LTRIM(RTRIM(column)) 

the trailing spaces remain.

You want to map to a VARCHAR() in SQL Server.

The CHAR() data type is fixed length with trailing spaces for shorter strings.

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