February 21, 2011 at 2:32 am
Hi there,
I am working on a SQL Server 2008 Database table that has over 1000 rows.
I need to update rows in a column by removing extra spaces between words. For example:-
TestColumnName
This is simple Data in a row
This is the second row
As you can see, this above rows have extra spaces in them. How do I update this column to have only a single space between words.
Kindly reply.
All comments and feedback are welcomed 🙂
Thank you!
February 21, 2011 at 3:45 am
February 21, 2011 at 5:19 am
thank you... replace function did the trick!
🙂
February 21, 2011 at 7:25 am
Now just one last thing. On the same column i have over 80 rows as:
87 02 A 52
87 02 A 53
87 02 A 54
87 02 A 55
...
I want to update them to:
87 02 52 A
87 02 53 A
87 02 54 A
87 02 55 A
...
that is, updating the alphabet 'A' from the 3rd place to the fourth place. Do I use the same replace function to accomplish this task. Kindly give me your recommendation 🙂
Thank you.
February 21, 2011 at 8:00 am
My first suggestion would be to separate these 4 pieces of data into their own columns. Barring that you will have to update using the substring function.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply