473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Trim function

hi all..
i have a doubt...how we can remove blank spaces
in a column value while retrieving?
i tried using LTRIM(RTRIM(COLUMN NAME))...
But it's removing only the leading and trailing spaces...
how i can remove spaces in between?
anybody please help...
thanks and regards,
Sand...
Nov 8 '06 #1
5 49459
scripto
143 100+
hi all..
i have a doubt...how we can remove blank spaces
in a column value while retrieving?
i tried using LTRIM(RTRIM(COLUMN NAME))...
But it's removing only the leading and trailing spaces...
how i can remove spaces in between?
anybody please help...
thanks and regards,
Sand...

Replace(COLUMN_NAME, " ", "")
Nov 8 '06 #2
I think that will erase all the spaces.
Trim should erase leading and trailing white spaces
oopps
your answer is correct, the other user requested to delete all spaces.
Apr 5 '07 #3
heberd
1
Look at http://sqltrim.codeplex.com for a function that will trim spaces from a string
May 14 '10 #4
replace(replace( cast(ba.heading1 as varchar),'<p>',''),'</p>','')
Jan 2 '12 #5
Expand|Select|Wrap|Line Numbers
  1. This should handle any variation of whitespace:
  2.  
  3. declare @text varchar(500)
  4. set @text = 'delete      white      space' -- add as many spaces between the words as you want...
  5. set @text = replace(replace(replace(replace(replace(@text,'     ',' '),'    ',' '),'   ',' '),'  ',' '),'  ',' ')
  6. print @text
  7.  
  8. Note: if you know that your whitespace count will never exceed 30 spaces, you can omit the '5 spaces' iteration.
  9. Important Note: don't click on 'Wrap' - it messes up the formatting. If you did click wrap, refreshing the page seems to return things to normal...
  10.  
Jan 30 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Simon | last post by:
Hi, I have written a function to trim char *, but I have been told that my way could be dangerous and that I should use memmove(...) instead. but I am not sure why my code could be 'dangerous'...
12
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the...
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
7
by: Sascha Herpers | last post by:
Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two...
22
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
31
by: rkk | last post by:
Hi, I've written a small trim function to trim away the whitespaces in a given string. It works well with solaris forte cc compiler, but on mingw/cygwin gcc it isn't. Here is the code: char...
12
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I trim whitespace - LTRIM/RTRIM/TRIM?...
5
by: Marjeta | last post by:
I'm trying to very that the user actually entered something in the form, and not just spaces. I guess the problem is in the first line of isBlank() function. I've tried the following:...
8
by: Keith Thompson | last post by:
Kevin Smith <no@spam.comwrites: You posted this to microsoft.public.dotnet.languages.csharp, where I presume it's topical. Why on Earth did you redirect followups to comp.lang.c? Anyone...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.