Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all


can any body tell me how can i split the string ,

i want something like this

given string 'sachin,rahul'

i want this result 'sachin', 'rahul'


tx in advance
Posted

SQL
DECLARE @FullName        VARCHAR(100)
SET @FullName = 'John,Doe'

SELECT SUBSTRING(@FullName, 1, CHARINDEX(',', @FullName) - 1) AS [FirstName],
       SUBSTRING(@FullName, CHARINDEX(',', @FullName) + 1, LEN(@FullName)) AS [LastName]


More Examples:

http://www.sql-server-helper.com/tips/split-name.aspx[^]
 
Share this answer
 
Comments
thatraja 24-Nov-11 13:59pm    
Right, 5!
Here other alternative ways

Split string in SQL[^]
 
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