Select fullname without familyname

Hello,
I have a table with names

UserTable(UserId int, Fullname(varchar(100))
Data:
UserId=1, Fullname='John Johnson'
UserID=2, Fullname='Bill William Howard'

I want to select Fullname from the table but not the last name.
From the example above I would like to get the result:
UserId=1, Fullname='John'
UserId=2, Fullname='Bill William'

Can you please help me with this?
johnson1Asked:
Who is Participating?
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
That's why usually is a separated field for LastName.
0
 
Shaun KlineLead Software EngineerCommented:
Something like this?
DECLARE @Name AS VARCHAR(100)

SET @Name = 'Bill William Howard'

PRINT LEFT(@Name, LEN(@Name) - CHARINDEX(' ', REVERSE(@Name)))

Open in new window

0
 
Scott PletcherSenior DBACommented:
That's extremely complex to do.  Search the web for some code that already has some of the issues with doing that identified and addressed.

For example:

'John Johnson II'
'Dr. Bill Watson'
'Manuel A. Pérez Quiñones'
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Werver Von Braun
Jean-Claude Van Damme
Charles de Gaulle
Karl Heins und Zu der Gossinger
0
 
Scott PletcherSenior DBACommented:
Claus Philipp Maria, Schenk Graf von Stauffenberg
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.