Click here to Skip to main content
15,881,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi ....

i have a table in which i am entering employee full name in one column ... like this -

id Empname LoanSubscriptionDate IsActive

1 Rohit Kumar 30/12/2013 1

2 BabuLal Tiwari 4/08/2012 0

3 Ramcharan Kumar Garg 9/11/2013 1





And i want a list of name which only contain first name , i.e. (as given result set of above table ) ---

Emp

Rohit
BabuLal
Ramcharan

Pls give any idea ...
Posted

 
Share this answer
 
Comments
GDdixit 28-Jan-14 5:45am    
there is nothing at the link....
Kornfeld Eliyahu Peter 28-Jan-14 5:48am    
Funny it leads me to a good article about string splitting in SQL...
Hi, assuming that after the first name you have a space you can try this:

SELECT LEFT(Empname, CHARINDEX(' ', Empname) - 1) AS FistName FROM YourTable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900