SQL Server | Other
Additional SQL Server features and topics not covered by specific categories
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
Now I have a table with a list of strings that are messy in format with spaces before and after them, and I need to update the table to remove the spaces before and after the strings. How do I do this?
Thanks!
Additional SQL Server features and topics not covered by specific categories
Answer accepted by question author
Hi @X M
You can try this.
create table test(col varchar(100));
insert into test values
(' asa '),
(' AD Lj'),
(' ad dag '),
(' U PF GH '),
(' V bag h a ');
;with CTE as(
select col,trim(col) as t from test)
update CTE set col = t;
Best regards,
Percy Tang