Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the length

Status
Not open for further replies.
Jun 17, 2004
73
US
I need to make the bold number dynamic. The query works fine. The problem is when I pull the data gets pulled, the javascript on this third party software does not like the ending spaces (The tracking numbers vary in length). If the software was ours I could fix it on that end but that is not an option the data has to go in with out spaces on the end. Is there any kind of TRIM command in SQL to cut off the extra spaces? I have tried rtrim. Maybe its not the white spaces?


Code:
INSERT INTO Table2 (Customerid, UserId, Comments,TrackingNumber,Comment_Date)
SELECT Customerid, UseridAdded, Line, '2|' + SUBSTRING ( Line , CHARINDEX('#', Line,2)+3 , [b]30[/b]),DateAdded
 From Table1
WHERE Line Like '%FEDX Tracking #%' OR Line Like '%FEDEX Tracking #%' AND Customerid = 'ABC123'

 
There is support for RTRIM, LTRIM, and TRIM. These functions only remove space characters. I suggest you take a look at the raw data using a hex editor. There are several freeware versions available on the internet if you do not have one.

-------------------------
The reasonable man adapts himself to the world. The unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. - George Bernard Shaw
 
There is a LTRIM and a RTRIM and if you used both they become TRIM..

I.e Select LTrim(Rtrim(' Somevalue '))
='somevalue'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top