April 28, 2009 at 5:32 pm
Adam Machanic (4/28/2009)
David Burrows (4/28/2009)
I split data with consecutive delimiters, ie a column/field with no dataIn most of the use cases I'm interested in, "a,,b,,c" with a delimiter of "," should return 3 rows
Adam, David,
I tend I agree with David on this: String.Split() has a handy optional parameter which allows you to ignore blank rows in the results - maybe something similar would be appropriate?
I think most people would expect '1,2,,3,,4' to expand to include blank rows, so that would make a sensible default.
Cue 'most people' telling me I'm wrong...:cool:
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 28, 2009 at 5:41 pm
Florian Reischl (4/28/2009)
Hierarchical data to be split? Well. This becomes really freaky... It would require either recursive methods or a much more complex RegEx which also becomes quiet slow.Flo
Hey Flo,
I didn't have anything so complex in mind - I'm not looking for something to replace XML :laugh:
The idea is to be able to split a string twice to produce a table result, but one to this one level, so:
"A~1,2,3`B~4,5,6`"
becomes
A 1
A 2
A 3
B 4
B 5
B 6
~ denotes the start of a record, and ` the end. Items are separated with a third delimiter.
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 28, 2009 at 5:42 pm
Flo,
Forget the articles.
You're looking at a book!!!
Cheers,
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 28, 2009 at 6:24 pm
Paul White (4/28/2009)
I didn't have anything so complex in mind - I'm not looking for something to replace XML :laugh:The idea is to be able to split a string twice to produce a table result, but one to this one level, so:
Hmm, that looks a lot like a replacement for XML to me 🙂
What's the use case?
--
Adam Machanic
whoisactive
April 28, 2009 at 6:46 pm
Adam Machanic (4/28/2009)
Hmm, that looks a lot like a replacement for XML to me 🙂What's the use case?
Optional 'attributes' of existing entities have been stored rolled up into a string of this sort and kept in a database table. It's the sort of thing that will be replaced by a sparse table, or an expanded relational schema at some stage, but for the time being, it is how it is.
I suppose I could use REPLACE with stringy XML tags to convert the delimiters to end up with a string which could be cast to XML, and then XQuery it, but that just feels horrible.
Cheers,
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 29, 2009 at 3:15 am
Paul White (4/28/2009)
Florian Reischl (4/28/2009)
Hierarchical data to be split? Well. This becomes really freaky... It would require either recursive methods or a much more complex RegEx which also becomes quiet slow.FloHey Flo,
I didn't have anything so complex in mind - I'm not looking for something to replace XML :laugh:
The idea is to be able to split a string twice to produce a table result, but one to this one level, so:
"A~1,2,3`B~4,5,6`"
becomes
A 1
A 2
A 3
B 4
B 5
B 6
~ denotes the start of a record, and ` the end. Items are separated with a third delimiter.
Paul
Hey Paul
This should be not a big problem in .Net but I think this will exclude the set based TSQL solutions. Sure it is possible with a "double-barreled"/"dual-carburetor" tally and a look-up for the previous parent information. I just suspect the performance will be not very good.
Greets
Flo
April 29, 2009 at 3:42 am
Paul White (4/28/2009)
You're looking at a book!!!
... or maybe something equal to http://www.connectionstrings.com/.
What about http://www.splitstrings.com? For string splitting in all programming languages (including the specials and esoteric!) C#, TSQL, C, Cobol, Whitespace, Lasso, J-Script, Ook ... .
:laugh:
Greets
Flo
April 29, 2009 at 3:51 am
Aw, just be done with it and create your own internet!
Flinternet? :blink:
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 29, 2009 at 4:26 am
Well, I think I keep the intend to write an/some article(s). 😉
April 29, 2009 at 5:46 am
@Adam
Sorry for the late feedback. I just tried your new CLR function. It works very good! The performance is alike my multi-character split method.
Thanks!
Flo
April 29, 2009 at 6:33 am
Paul White (4/29/2009)
Aw, just be done with it and create your own internet!Flinternet? :blink:
Paul
Flonternet?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 29, 2009 at 6:36 am
Jack Corbett (4/29/2009)
Flonternet?
:laugh: :laugh: :laugh:
Better, yes.
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 29, 2009 at 7:57 am
Jack Corbett (4/29/2009)
Paul White (4/29/2009)
Aw, just be done with it and create your own internet!Flinternet? :blink:
Paul
Flonternet?
Which character is the delimiter?
😀
April 29, 2009 at 6:06 pm
Paul White (4/28/2009)
Florian Reischl (4/28/2009)
Hierarchical data to be split? Well. This becomes really freaky... It would require either recursive methods or a much more complex RegEx which also becomes quiet slow.FloHey Flo,
I didn't have anything so complex in mind - I'm not looking for something to replace XML :laugh:
The idea is to be able to split a string twice to produce a table result, but one to this one level, so:
"A~1,2,3`B~4,5,6`"
becomes
A 1
A 2
A 3
B 4
B 5
B 6
~ denotes the start of a record, and ` the end. Items are separated with a third delimiter.
Paul
http://www.sqlservercentral.com/articles/T-SQL/63003/
--Jeff Moden
Change is inevitable... Change for the better is not.
April 29, 2009 at 6:27 pm
Jeff Moden (4/29/2009)
http://www.sqlservercentral.com/articles/T-SQL/63003/
Thanks Jeff,
I have read that before, and use that approach currently.
When Adam asked for ideas to extend the string-split, this came to mind.
It would be interesting to compare the two approaches...
It's a great article by the way.
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 15 posts - 316 through 330 (of 522 total)
You must be logged in to reply to this topic. Login to reply