Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
lol...finally my turn to play substring...in case i got these dataraw datahi|aaa|what are you doing|bbb|imagine what you can done|ccc|haha|ddd|hi|aaa|wahahahah|ccc|what else|eee|harlo|aaa|this|bbb|is|ccc|totally|confusing|eee|need|hhh|help|zzz|!!!now those value between '|aaa|' or etc is a delimiter, however the delimiter does not always in the totally correct ordering..so how do i separate those value before, between and after the delimiter into columns?Hope can help...but advise to wait pros with confirmation...
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2009-08-27 : 03:42:46
One of the methods
declare @s varchar(1000)set @s='hi|aaa|what are you doing|bbb|imagine what you can done|ccc|haha|ddd|'declare @t table(id int identity(1,1),data varchar(1000))while charindex('|',@s)>0begin insert into @t(data) select substring(@s,1,charindex('|',@s)-1) set @s=substring(@s,charindex('|',@s)+1,len(@s))endselect data from @twhere id%2=1
MadhivananFailing to plan is Planning to fail
waterduck
Aged Yak Warrior
982 Posts
Posted - 2009-08-27 : 03:45:23
erm...madhi...is divide them into column..not rows...you can assume '|aaa|' is a delimiter that divide a full string into columnHope can help...but advise to wait pros with confirmation...
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2009-08-27 : 03:50:02
quote:Originally posted by waterduck erm...madhi...is divide them into column..not rows...you can assume '|aaa|' is a delimiter that divide a full string into columnHope can help...but advise to wait pros with confirmation...
ahhaha thx madhi...i go try first...Hope can help...but advise to wait pros with confirmation...
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2009-08-28 : 03:16:32
Are you able to solve it?MadhivananFailing to plan is Planning to fail
waterduck
Aged Yak Warrior
982 Posts
Posted - 2009-08-28 : 03:29:47
kinda busy at my front end thingy...wait till i got time to solve it....sorry madhiHope can help...but advise to wait pros with confirmation...
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2009-08-28 : 03:34:26
quote:Originally posted by waterduck kinda busy at my front end thingy...wait till i got time to solve it....sorry madhiHope can help...but advise to wait pros with confirmation...
Ok Fine. Which front end are you working on?MadhivananFailing to plan is Planning to fail