I found tons of articles stating you can remove spaces like this:
update mytable set Name=TRIM(Name)
UPDATE mytable SET Name = LTRIM(RTRIM(Name))
My columns is nvarchar have I misunderstood something, because my column names still have spaces in start and end of the values like below:
'Der_j_McD '
Check the below;
Try
UPDATE Table SET [Column] = REPLACE(REPLACE(LTRIM(RTRIM([Column])),CHAR(10),''),CHAR(13),'')
Assuming that you want to trim all spaces, tabs, carriage return and line feeds you need to use the TRIM
function like so:
UPDATE t SET name = TRIM(CHAR(13) + CHAR(10) + CHAR(9) + ' ' FROM name)
This requires SQL Server 2017 or later.
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.