Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Separate Words In Sentence
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Brittney10
Posting Yak Master

USA
154 Posts

Posted - 12/10/2012 :  17:32:44  Show Profile  Reply with Quote
I need to be able to separate words in a sentence and insert them as their own record. For example, I have a record that needs inserted:


ID_____Name (str)
1______Name One
2______Name Two
3______Name Three


I need 6 records to be inserted from the above 3 records (note the IDs)

ID_____Name (str)
1______Name
1______One
2______Name
2______Two
3______Name
3______Three


Any help or direction on this would be greatly appreciated. I'm actually trying to achieve this in SSIS, but figured I could also do it in SQL as well.

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 12/10/2012 :  18:59:44  Show Profile  Reply with Quote
SSIS is probably a better place for this kind of thing. But, if you want to do it in SQL then one option is to get Parse/Split function. Here is one of the better ones:
http://www.sqlservercentral.com/articles/Tally+Table/72993/
Go to Top of Page

Brittney10
Posting Yak Master

USA
154 Posts

Posted - 12/11/2012 :  09:02:32  Show Profile  Reply with Quote
I would prefer to do it in SSIS, if you have a good idea of how to do this?
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 12/11/2012 :  11:41:18  Show Profile  Reply with Quote
Here is one example, if you do a search you'll find many more:
http://bi-polar23.blogspot.com/2008/06/splitting-delimited-column-in-ssis.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000