How to split fullname into first and lastname in SQL, Excel and SSIS

Excel:

Firstname
=LEFT(A2,FIND(" ",A2,1)-1)

Lastname
=RIGHT(A2,LEN(A2)-FIND(" ",A2,1))

SQL query:

SELECT 
  [fullname],
  LTRIM(RTRIM(SUBSTRING(fullname, 1, CHARINDEX(' ', fullname)))) AS FirstName,
  LTRIM(RTRIM(SUBSTRING(fullname, CHARINDEX(' ', fullname) + 1, 8000))) AS LastName
FROM [SANDBOX_TABLES]

SSIS Derived Column

Firstname:
LEFT([FIELD],FINDSTRING([FIELD]," ",1) - 1)

Lastname:
RIGHT([FIELD],LEN([FIELD]) - FINDSTRING([FIELD]," ",1))
Comment List
Related
Recommended