DECLARE@FullName VARCHAR(100)
SET@FullName ='David'
SELECT
SUBSTRING(@FullName, 1,NULLIF(CHARINDEX(' ', @FullName)- 1,-1))AS [FirstName],
SUBSTRING(@FullName,CHARINDEX(' ', @FullName)+ 1,LEN(@FullName))AS [LastName]