Link to home
Start Free TrialLog in
Avatar of romeiovasu
romeiovasu

asked on

sql query spaces

hi all i have my data like this
MP1M A
QX31 S
MP1M A
FA20 S
FA20 S
PTTF      P        F
FN3NM0014 P        S
FN3NM0014 P        S
FN3NM0014 S        S
FN3NM0014 S        S
FN3NM0014 S        S
FN3NM0014 S        S

i want to remove all the data after the first space. i dont want anything after the first space.  how can i write a query the filed name for this "billcode"  

ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of romeiovasu
romeiovasu

ASKER

aneesh how do you do this in access
All you need to do is find the index (location) of the first space and if it does exist, then do a LEFT on that length:

SELECT
      LEFT(billcode, CASE WHEN CHARINDEX(' ', billcode) = 0 THEN LEN(billcode) ELSE CHARINDEX(' ', billcode) END) AS billcode
FROM
      TableName
how to do the same thing in access