Give an example of ParseName function?

 Posted by vishalneeraj-24503 on 11/3/2014 | Category: Sql Server Interview questions | Views: 378 | Points: 40
Answer:

DECLARE @Fruits VARCHAR(50);

SET @Fruits = 'Mango Apple Orange';

SELECT PARSENAME(REPLACE(@Fruits, ' ', '.'), 3),

PARSENAME(REPLACE(@Fruits, ' ', '.'), 2),

PARSENAME(REPLACE(@Fruits, ' ', '.'), 1)

Output:-
Mango Apple Orange

Here,we have replaced space with Dot(.) and based on Dot positions,we are extracting fruit names.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response