?
Solved

sql query spaces

Posted on 2007-11-29
4
Medium Priority
?
240 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 2000 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

Independent Software Vendors: 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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

752 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