Reputation:
I have a field like
BestStreet 123/56
and I want to get
BestStreet
I've tried:
LEFT(sd.UliceCP, CHARINDEX(' ', sd.UliceCP)-1)
Upvotes: 1
Views: 65
Reputation:
Using Substring Also we can get the same
SELECT SUBSTRING(sd.UliceCP,0,CHARINDEX(' ',sd.UliceCP))
Upvotes: 0
Reputation: 81970
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)
Upvotes: 5