In this post i would like to show you a simple technique to split the full name. There are various techniques available to do the same using LEFT, RIGHT,SUBSTRING, CHARINDEX functions.
DECLARE @SQLVariable VARCHAR(100);
SET @SQLVariable = 'Vijaya.Krishna.Kadiyala.SQL Server';
select PARSENAME(@SQLVariable,1) AS Technical_Skill;
select PARSENAME(@SQLVariable,2) AS LAST_NAME;
select PARSENAME(@SQLVariable,3) AS MIDDLE_NAME;
select PARSENAME(@SQLVariable,4) AS FIRST_NAME;
Output:
Technical_Skill
-----------------
SQL Server
(1 row(s) affected)
LAST_NAME
-------------------
Kadiyala
(1 row(s) affected)
MIDDLE_NAME
-------------------
Krishna
(1 row(s) affected)
FIRST_NAME
-------------------
Vijaya
(1 row(s) affected)
Reference : Vijaya Kadiyala (www.DotNetVJ.com)
Monday, February 1, 2010
Split Full Name into First Name, Middle Name, Last Name in SQL Server using PARSENAME function
Labels:
DotNetVJ,
SQL Server,
Vijaya Kadiyala
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment