SqlShare.com Logo
 
Skip Navigation Links
Home
Video List
Events
Classes
About Us
Login / Register
Subscribe RSS Feed 

Confio Ignite

Splitting Delimited Strings

It's not something we'll do often, but it's a useful tool to have - especially if you want to let Reporting Services users select multiple values and pass them to a stored procedure. We'll look at two techniques, one that uses the TABLE variable, and one that works all the way back to SQL 2000 by building an XML string and using OpenXML.

Duration:
8 mins 47 secs
Skill Level:
100
Rating:
4.45 out of 5
Publish Date:
June 02, 2010
Splitting Delimited Strings You must be logged in to view this video.  
Bookmark and Share
 
1=Poor, 3=Good, 5=Excellent

About the Author

Image of Andy Warren
Andy Warren is a software trainer focusing on SQL Server, a member of the PASS Board of Directors, and a principal in this site - SQLShare.com.

References



Comments
Boris Shimonov on 6/2/2010
I couldn't get script. Would be possible to get your scripts. My email address is bshimonov@loews.com Thank you.

dba on 6/2/2010
By the looks of the SP, I take it that you're not familiar with the tally/numbers table technique. In case my assumption is correct, I would suggest that you have a look at the following page. I was very much impressed with this technique and its applications that are mentioned in the article. http://www.sqlservercentral.com/articles/T-SQL/62867/ Best regards, Henk

Mike Salo on 6/2/2010
I don't see why use a xml document to store the delimited values for non-2008 sql severs. I would just build a temp table in the stored proc and select from for it to return the values in a similar fashion as in SQL Server 2008 example. You will get the same results no matter which version of sql server you are running using a temp table.

Ralph Schwehr on 6/2/2010
Good information. Had to do that a few times in the past and developed my own parce string functions without the xml option however.

Roopesh on 6/2/2010
I also could not get the scripts. Could you also email this to rupeshdas@hotmail.com. The articale looks interesting.

Bryan Geiger on 6/2/2010
great video, thanks

Kevin on 6/2/2010
Awesome video Andy. Keep it up.

Dennis Allen on 6/2/2010
I am confused by your statement that table as a return type is only available in 2008. I have been using table value functions in SQL 2000. Perhaps I misunderstood. Also, for this sort of parsing, I was expecting a tally table and I would like to know why this was not the solution chosen. I can think of many reasons, but would like to hear more about your reasons. Love the site and the videos!

Jeff Moden on 6/2/2010
Gosh... I can't rate this. The XML part and the whole concept is outstanding. I just can't condone the use of a mTVF (multi-line Table Valued Function) with RBAR in it instead of using a very high speed iTVF (inline Table Valued Function) and some form of a Tally/Numbers table to replace the While Loop. Feel free to contact me if you have any questions about this comment. --Jeff Moden jbmoden@ameritech.net

Jamshid Nouri on 6/3/2010
excellent demo

Bob Grinde on 6/3/2010
Scripts link is broken. Could you please send the scripts to bob.grinde@wonderwaremidwest.com as well. Thanks

ewart on 6/3/2010
SQL Server 2000 has RETURNS @t TABLE in a function call.

Douglas Kemp on 6/3/2010
Liked the technique comparison between versions

Cedric Walker on 6/3/2010
sweet. wish I had the code available for me to try.

Fernando on 6/3/2010
d

Sitaram Lanka on 6/3/2010
please email code to slanka11@gmail.com

glyn on 6/4/2010
Very good. clear instructions and easy to follow.

Andy Warren on 6/4/2010
Fixed the script link, sorry!

Andy Warren on 6/4/2010
Dennis/Jeff, I know the tally number approach and it's valid, in this case I went with something different, mainly to focus on the mechanics of using functions for interesting things.

Christian Bahnsen on 6/4/2010
Andy, you rock!

32DE12EB89 on 6/5/2010
Great stuff. Probably too much for one video but valuable and useful.

Desmond Cassidy on 6/6/2010
Very eleoquent English speaker..(use this guy for ALL your videos) ...One thing I lke to do is to enhance the functionality of functions via boolean switches..e.g. DoNotTrim, IgnoreNullOrEmptyValues etc

Sreedhar on 6/7/2010
Excellent Video. Thank you

Rodney on 6/7/2010
Great stuff Andy....thanks for the commented ack.

MattC on 6/9/2010
Another option to aviod the XML approach in 2005 would be using a table valued function

Paul E Richmond on 6/11/2010
Excellent presentation.....

ajith on 6/12/2010
Gud one.....

89C8641EBF on 6/28/2010
just excellent...!! keep on doing this..!!

WChaster on 7/14/2010
In the examples --leading delimiter with no value, does produces one row of null for the first coma, but what happened to the last coma it does not produce a row? In --no trailing delimter, it does not have a trailing delimiter. I needed this functionality before to parse a multi-valued column but the solution was more complex that this. This is better.

nilesh bilimoria on 11/17/2010
nicely done

Fred Fowler on 8/26/2011
Clean and direct. Followed by the use case. Very effective. Thank you for sharing.

John O'Sullivan on 1/1/2012
excellent splitter function

T. Carnahan on 1/16/2012
Little fast paced. Would be nice if he provided the code for his function as a sample.



Must Be Logged In
 

How Do I Become a Video Author? |  Newsletter History

Copyright © Fourdeuce, Inc., 2005-2009. All Rights Reserved | Privacy Policy | Terms & Conditions