.Net ramblings
# Friday, 13 April 2007
SQL: Display full name in "Surname, Firstname" format.
not the most elegant solution you'll ever see, but i find it very useful when i don't want to store several columns for the different parts of a person's name in a database table.
it takes the surname based on the last space in the name.  so "Paddy Joe Gonzales" will be listed as "Gonzales, Paddy Joe".
Right(FullName, PatIndex('% %', Reverse(FullName))) + ', ' + Left(FullName, Len(FullName) - PatIndex('% %', Reverse(FullName)))    

Friday, 13 April 2007 14:13:30 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  Database