SQLTeam.com | Weblogs | Forums

EXTRACT String for cell


#1

Hi
When I have 'TWO DAYS' in a string i want to extract 'TWO' but if i use this code below and only have 'TWO' in the cell it returns an empty value :

SUBSTRING(fieldname,0,CHARINDEX(' ',fieldname,0)) 

I'ld like to return the first word of every cell ...

Thanks in advance
Didier


#2

LEFT(fieldname,CHARINDEX(' ',fieldname + ' ') - 1)


#3

Thanks again Scott :slight_smile: