Skip to content
Advertisement

TRIM function on SQL Server 2014

IN SQLite I wrote :

UPDATE MYTABLE SET MYFIELD = TRIM(MYFIELD);

What to do to have this on SQL Server 2014 ?

Advertisement

Answer

UPDATE MYTABLE SET MYFIELD = LTRIM(RTRIM(MYFIELD));

However, field type must be varchar() and not text. Otherwise you get “Argument data type text is invalid for argument 1 of rtrim function”

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement