Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
split column
split column
Rate Topic
Display Mode
Topic Options
Author
Message
DBayliss
DBayliss
Posted Monday, September 10, 2012 4:37 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 9:04 AM
Points: 10,
Visits: 99
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.
Post Attachments
split.xlsx
(
14 views,
10.53 KB
)
Post #1356639
Andy Hyslop
Andy Hyslop
Posted Monday, September 10, 2012 4:50 AM
Mr or Mrs. 500
Group: General Forum Members
Last Login: Yesterday @ 1:50 AM
Points: 595,
Visits: 2,138
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
Post #1356648
Fantastica
Fantastica
Posted Wednesday, October 10, 2012 6:11 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, October 10, 2012 9:18 AM
Points: 2,
Visits: 6
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/
Even has an example of how to make sure that any other columns of data are moved along with the split values.
Post #1370874
Sean Lange
Sean Lange
Posted Wednesday, October 10, 2012 7:56 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Yesterday @ 10:26 PM
Points: 8,606,
Visits: 8,247
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/
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 Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Post #1370933
Fantastica
Fantastica
Posted Wednesday, October 10, 2012 8:43 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, October 10, 2012 9:18 AM
Points: 2,
Visits: 6
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 ;)
Post #1370977
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.