Thursday, October 8, 2015

Select data from string up to a space in SQL Server?

You can use a combiation of LEFT and CHARINDEX to find the index of the first space, and then grab everything to the left of that.

SELECT LEFT(YourColumn, charindex(' ', YourColumn) - 1)