Skip to content
Advertisement

Split Full Name with Format: {Last, First Middle} Comprehensive Cases

My client sent me name data as a Name string which includes the last, first, and middle names in a single entry. I need them split into LastName, FirstName, and MiddleName. I have found some scripts online, but they don’t serve my purposes because they either (1) use a different format, or (2) don’t handle edge cases very well. See the examples below:

  1. Nightingale, Florence -> Florence Nightingale
  2. Bond, James Bond -> James Bond Bond
  3. Abbott, Edwin A. -> Edwin A. Abbott

Can someone help me write a SQL Server script that splits a string into the various pieces I’m looking for?

Advertisement

Answer

Please note the following:

  1. Always request normalized data to ensure the highest data quality. I tried to enumerate all possible cases for last, first, and middle name combinations but I’m sure I did not get all of them.
  2. My script requires the format: LastName@DELIMITER1@DELIMITER2FirstName@DELIMITER2MiddleName, but can be easily altered for other formats.
  3. This script does not separate tiles like Dr., or handle suffixes.
  4. Credit to MemKills for the idea of the test data set, which I expanded.

>

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement