TOP

SQL split fullname

Example: #1

SELECT fullname ,reverse (substring(reverse(fullname),1,charindex(‘ ‘, reverse(fullname)))) as LName, substring(fullname,1,charindex(‘ ‘, fullname)) as FName
FROM [salesreps].[dbo].[salesreps_1]

Example: #2

SELECT fullname ,substring(fullname,charindex(‘ ‘, fullname), LEN(fullname)) as LName,
substring(fullname,1,charindex(‘ ‘, fullname)) as FName
FROM [salesreps].[dbo].[salesreps_1]

Comments are closed.