September 10, 2012 at 4:37 am
Hi, I'm trying to split a single column into a number of columns, with the split being the delimiter of '-'
I have enclosed an excel example of what I am trying to achieve.
If anyone could help, that would be great
Thanks in advance for your help.
September 10, 2012 at 4:50 am
Hi
Take a look at this link:
http://www.sqlservercentral.com/articles/Tally+Table/72993/
Andy
==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
October 10, 2012 at 6:11 am
October 10, 2012 at 7:56 am
Fantastica (10/10/2012)
Bit of a late answer, but found this usefull when I had this same problem.http://www.syntaxwarriors.com/2012/t-sql-splitting-strings-into-multiple-rows/[/url]
Even has an example of how to make sure that any other columns of data are moved along with the split values.
The article reference by Andy explains why the process at the link you posted will work but performs a lot slower.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
October 10, 2012 at 8:43 am
Maybe I'm reading it wrong, but short of going into CLR (which I personally try to avoid for maintainability) CTE dosen't seem to be much slower?
I mostly liked the link I provided for it's simplicity, but then again I'm not in need of break neck speeds, my script will only be running about once per day when noone else is logged in, so a couple of extra milliseconds wont matter 😉
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply