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

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Delimit values in a column into rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SlimJimHymns
Starting Member

1 Posts

Posted - 04/27/2013 :  16:17:29  Show Profile  Reply with Quote
Hi,
I having trouble taking the below type of column and delimiting it into rows. See below:

Table1
ID BatchNum
543 455/544/655

Table2
ID BatchNum
543 455
543 544
543 655

Thanks,

James K
Flowing Fount of Yak Knowledge

3326 Posts

Posted - 04/28/2013 :  08:24:09  Show Profile  Reply with Quote
You need a string parser - the best one by far that I have seen is Jeff Moden's code here: http://www.sqlservercentral.com/articles/Tally+Table/72993/ Copy the code from Figure 21 in his article to an SSMS query window, and run it - which will install the function. Then use it like this:
select
	t.id,
	d.Item as BatchNum
from
	YourTable t
	cross apply
	( select * from  dbo.DelimitedSplit8K( t.BatchNum,'/')) d
order by
	id, ItemNumber;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 04/29/2013 :  01:00:08  Show Profile  Reply with Quote
just another way

http://visakhm.blogspot.com/2013/01/delimited-string-split-xml-parsing.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.03 seconds. Powered By: Snitz Forums 2000