How to Split Sql String like this

Posted by Jayakumars under ASP.NET AJAX on 5/3/2012 | Points: 10 | Views : 1613 | Status : [Member] [MVP] | Replies : 6
hi

How to Split this String in my Requirements.

My Sql data like this
Id Name
1. |Jaya|R|Kumar|

But i need output this
Id Name
1 Jaya Kumar

Mark as Answer if its helpful to you


Responses

Posted by: Sabarimahesh on: 5/3/2012 [Member] Bronze | Points: 25

Up
0
Down
http://dirk.net/2007/05/07/split-like-string-to-array-function-in-transact-sql/

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patil_Rakesh on: 5/4/2012 [Member] Starter | Points: 25

Up
0
Down

HI Jayakumars,

If ("Life is a Race " =true)
{
"Then CHASE it, BREAK it , :) below is your solution "
}

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

declare @id varchar(10), @final varchar(max)=''

select @id=substring('1. |Jaya|R|Kumar| ',0,charindex('.','1. |Jaya|R|Kumar| '))

set @final=substring('1. |Jaya|R|Kumar| ',charindex('.','1. |Jaya|R|Kumar| ')+1,len('1. |Jaya|R|Kumar| '))

declare @site as varchar(max)
set @site = @final

declare @names as varchar(MAX)
set @final=''
while charindex('|',@site) > 0
BEGIN
select @names=substring(@site,1,(charindex('|',@site)-1))

set @final=@final+' '+@names

SET @site = substring(@site,charindex('|',@site)+1,len(@site))
END
print RTRIM(@id)+' '+LTRIM(@final)

Thanks & Regards
By
Rakesh patil

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Manningsrachel on: 5/5/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks sabarimahesh.

[url=http://www.edwardhighschool.com]Online diploma[/url]

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Krushika on: 5/5/2012 [Member] Starter | Points: 25

Up
0
Down
y u want tht?

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 5/7/2012 [Member] Bronze | Points: 25

Up
0
Down
Manningsrachel


If you feel my Post as a Answer ... Please Mark As Answer

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 5/7/2012 [Member] Bronze | Points: 25

Up
0
Down
Manningsrachel

Welcome

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response