Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: TRIM Function

  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TRIM Function

    Hi there...

    My column from a table in sql has value "NEW" and sometimes "NEW ".....thats with 2 spaces behind it...

    How do i get rid of it in my sql or asp....someone suggested TRIM??

    Thanks!!

    mysql="SELECT * FROM Test WHERE number='10'"
    Set rs= Con.Execute( mySQL )

    if rs("status")="NEW" then
    ...
    else
    ...
    end if

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Is there ever a time where you want spaces trailing non-spaces in that column? If not, then you can just do a mass UPDATE query to trim every row:

    Code:
    UPDATE myTable
    SET myColumn = RTRIM(myColumn)

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry I think this should have been as asp question...

    Coz its not the update thats causing problem but its retrieving value from the database tht might sometimes have "NEW" or "NEW ". So i should probably do something in asp to get rid of those 2 spaces in my condition of if..else..end if...

    What say??

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    My suggestion was to execute a one-time query that will clean up the data in your table, but if you want to prevent the extra spaces from ever being written to the table, you'll want to ask for this thread to be moved to the ASP forum so someone can help you with that.

    WHAT YOU SAY!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •