I have a database where a name is in one field, how can I split this data on the space so I get a first name and last name value, but the caveat is that there is the case when there is no space so would only have a first name.
How can I achieve this?
Create Table Data
(
FullName varchar(200)
)
Insert Into Data Values ('Jason Jones'), ('Mark Smith'), ('Ted')
Select
FirstName =
,LastName =
From Data
My SQL Version is Microsoft SQL Server 2016 and my desired output would be
case 1 -
FirstName = Jason
LastName = Jones
case 2 -
FirstName = Mark
LastName = Smith
case 3 -
FirstName = Ted
LastName =
