Forum Discussion

Anonymous's avatar
Anonymous
Jun 17, 2019

How to remove extra spaces for SQL data

Hi Everyone,

 

I am pulling data from my inventory, but the Item# have extra spaces so i can't use vlookup in Excel. Can you please show me how to remove the extra trailing and leading space? such as where to enter the formula and how in SQL?

 

Thank you in advance!

4 Replies

  • MickeNy's avatar
    MickeNy
    Copper Contributor
    Have you tried TRIM which should drop the extra spaces?
    • Anonymous's avatar
      Anonymous

      Hi MickeNy 

       

      How do you ensert the Trim function in SQL statement? Sorry  I am very new to SQL

       

      Thank you

      • MickeNy's avatar
        MickeNy
        Copper Contributor

        Deleted I’m not sure how to do it within an SQL statement but assuming that you have a faulty value in your sheet that you want to use in a sql query you would first apply the TRIM to the faulty cell reducing the leading and trailing spaces from it and then use the resulting cell as your sql-statement source.

         

        sample: a1 contains ”   Abc   ”

        Writing the following formula TRIM(a1) in a2 would make a2 content ”Abc”

        Then you would use a2 in your sql statement to find what ”Abc” stands for.

         

        I hope this helps!

Resources