Solved

sql query spaces

Posted on 2007-11-29
4
236 Views
Last Modified: 2010-03-19
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"  

0
Comment
Question by:romeiovasu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 20375071
SELECT LEFT(urColumn, CHARINDEX(' ', urColumn)-1 )
0
 

Author Comment

by:romeiovasu
ID: 20375103
aneesh how do you do this in access
0
 
LVL 8

Expert Comment

by:digital_thoughts
ID: 20375123
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
0
 

Author Comment

by:romeiovasu
ID: 20375159
how to do the same thing in access
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question