sql 2005 query spaces

hi i have a column called code where the data is stored as
a b
ab c
abc d
adc d
acb c

i want to write a query to show only the data before the spaces, i dont want any data after the spaces like

how can i get in using a sql query
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Select left(YourField+' ',Instr(YourField,' ')-1)...
RyanProject Engineer, ElectricalCommented:
There may be a more efficient way, but heres one I did real quickly.
It selects loc just to hold the location of the first space - kinda like a variable.

SELECT Left([teamname],IIf([loc],[loc],Len([teamname]))) AS Expr1, InStr(1,[TeamName],' ') AS loc
FROM tblTeams;
so that you won't have any errors when yourfield doesn't contain any spaces:

Select case when Instr(YourField,' ')>1 then left(YourField+' ', Instr(YourField,' ')-1) else YourField end as NoSpace

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
romeiovasuAuthor Commented:
Thank you
romeiovasuAuthor Commented:
than k u
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.