SQL Server 2012
I've inherited a database which has several tables which contain a FullName field, but no FirstName or LastName field.
I know this is problematic, and at best will be a 95% solution, but I need a SQL query which will split the FullName column which looks like:
I know this is going to involve maybe a couple of Case statements, but I'm uncertain how to parse for the text to the right or left of the comma/first space. I know it will look something like:
CASE WHEN [FullName] LIKE '%,%' everything left of comma
ELSE everything to the right of the first space END as LastName,
CASE WHEN [FullName] Like '%,%' everything right of the comma
ELSE everything to the left of the first space END as FirstName