1

I have a field like

BestStreet 123/56

and I want to get

BestStreet

I've tried:

LEFT(sd.UliceCP, CHARINDEX(' ', sd.UliceCP)-1)

2 Answers2

5

You may want to add a space, just in case one does not exist.

For example: Notice the sd.UliceCP+' '

LEFT(sd.UliceCP, CHARINDEX(' ', sd.UliceCP+' ')-1)
John Cappelletti
  • 79,615
  • 7
  • 44
  • 66
0

Using Substring Also we can get the same

SELECT SUBSTRING(sd.UliceCP,0,CHARINDEX(' ',sd.UliceCP))