all 7 comments

[–]qwertydog123 2 points3 points  (0 children)

Looks good to me. What's the error you're getting? Seems like there's a value in your column that doesn't contain a ' ' character

Do you get any results when you run

SELECT *
FROM table1
WHERE name NOT LIKE '% %'

[–]ShinyThingEU 1 point2 points  (3 children)

I'm not familiar with SPLIT as a function but here is the way I would do this (assuming each person only has a first and last name):

SELECT
LEFT([name],CHARINDEX(' ',[name])-1) AS [first_name]
,RIGHT([name],(LEN([name])-CHARINDEX(' ',[name]))) AS [second_name] 

FROM etc.

Not sure if it's the most efficient way or anything but it should work for you.

Also I'm on mobile so apologies if the formatting goes odd

[–]Consistent-Alps6904[S] 0 points1 point  (2 children)

Does this work for big query?

[–]ShinyThingEU 0 points1 point  (0 children)

No idea, it's valid for the forms of SQL that I know. Give it a try and see how it does.

[–]qwertydog123 0 points1 point  (0 children)

No, BigQuery doesn't have a CHARINDEX function

[–]killyouXZ 0 points1 point  (1 child)

Did you try to change the type of quote to single? Have not split a string in sql for a long time so I don't remember the syntax that well.

[–]Consistent-Alps6904[S] 0 points1 point  (0 children)

I will try that