How can I use LTRIM RTRIM to search and replace leading trailing spaces

0 votes

I'm attempting to remove leading and trailing spaces from an NVARCHAR(MAX) column that contains price information (using NVARCHAR due to data importing from multiple operating systems with odd characters).

The leading and following spaces from static prices can now be removed using a t-SQL statement. I'm at a loss for how to use this identical command to eliminate all pricing, though.

The static script I used to eliminate particular pricing is shown here:

UPDATE *tablename* set *columnname* = LTRIM(RTRIM(2.50)) WHERE cost = '2.50 ';

Here's what I've tried to remove all the trailing spaces:

UPDATE *tablename* set *columnname* LIKE LTRIM(RTRIM('[.]')) WHERE cost LIKE '[.] ';

I've also experimented with various the% for random character variations, but I'm currently at a loss for ideas.

I want to remove all the leading and following spaces from each cell in this column with just one straightforward command, without changing any of the column data itself.

Sep 8 in Database by Kithuzzz
• 12,240 points
26 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

I have to build a school website How can i connect databases to the instance (ec2) and what is the best AMI for my webserver INAWS ???

Hi@Trinu, I don't think your database is depends ...READ MORE

answered May 4, 2020 in Database by MD
• 95,360 points
326 views
0 votes
1 answer

How can I connect databases server to EC2 server?

Hi@Trinu, You can create one database in AWS ...READ MORE

answered May 1, 2020 in Database by MD
• 95,360 points
451 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9 in Database by Neha
• 8,920 points
167 views
0 votes
0 answers

How would I use excel to generate a large update sql statement?

I know there's a way to have ...READ MORE

Mar 30 in Database by Edureka
• 13,640 points
116 views
0 votes
0 answers

How can I add the sqlite3 module to Python?

Can someone please explain how to install ...READ MORE

Sep 6 in Database by Kithuzzz
• 12,240 points
15 views
0 votes
1 answer

How will I get all the rows from my table where name starts with 's' and ending with 'I'?

Hi Santanu, I understand your problem, You can try ...READ MORE

answered May 28, 2019 in Database by sampriti
• 1,120 points
650 views
0 votes
1 answer
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 7,020 points
121 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 7,020 points
45 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
216 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP