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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find records with leading blank spaces

Status
Not open for further replies.

RJL1

Technical User
Oct 3, 2002
228
US
I have a table where some times the user enters a container number but presses the space button onece or twice. I like to write a query to return all records with leading blank spaces

What is the best way to do this?

Code:
SELECT
I.ROWNUM,
I.CONTAINER_ID
FROM
IT_DATA_SHIPPING I
WHERE
?????

Code:
ROWNUM      CONTAINER_ID
1           932566854711
2             932566854821
3           932566854960

Only row 2 need to be returned

Thanks for any help
RJL
 
[tt]
WHERE CONTAINER_ID Like ' %'
[/tt]

You can remove leading spaces from your data like this:

Code:
UPDATE IT_DATA_SHIPPING
SET    CONTAINER_ID = RTRIM(CONTAINER_ID)
WHERE  CONTAINER_ID Like ' %'


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top