Using PARSENAME Function to split First name.Middle name and Last name

Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 1097
PARSENAME function works as Dot Net Split function ,As Split method is used to separate deliminated values and using index we can get value. PARSENAME function works same.
For Example:-
SET @FullName = 'Vishal Kumar Neeraj'

SELECT PARSENAME(REPLACE(@FullName, ' ', '.'), 3) AS [First_Name],
PARSENAME(REPLACE(@FullName, ' ', '.'), 2) AS [Middle_Name],
PARSENAME(REPLACE(@FullName, ' ', '.'), 1) AS [Last_Name]

First_Name Middle_Name Last_Name
Vishal Kumar Neeraj

Comments or Responses

Login to post response