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
 Transact-SQL (2008)
 question concatanating
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

joe8079
Posting Yak Master

USA
113 Posts

Posted - 05/15/2012 :  11:08:08  Show Profile  Reply with Quote
Hi, I have a very complicated issue and I don't know where to go.
Basically, I need a way to concatanate lines 1-3 into one string and keep all the commas. The desired output is below. In my database, I have over 3.5 million records that look like this and some have ten of the same box with a different for each box. It would need to show one unique box by somehow concatanting all the columns below it. My co worker suggested some kind of loop, but I have no idea where to even begin. Also, the loop would have to run like 3.5 million times so I'm not sure how this would affect performance. Any help would be greatly appreciated.



Box String:
B3399 ,123, , ,
B3399 ,345 , ,
B3399 ,123, 41, ,
Desired output:

Box String
B3399 ,123, , , ,345 , , ,123, 41, ,

Edited by - joe8079 on 05/15/2012 11:11:24

joe8079
Posting Yak Master

USA
113 Posts

Posted - 05/15/2012 :  11:12:23  Show Profile  Reply with Quote
just so its clear, the Box is B3399 and the column for String starts with a ,
Its two separate columns and the formatting got messed up when I posted it.
Go to Top of Page

joe8079
Posting Yak Master

USA
113 Posts

Posted - 05/15/2012 :  19:29:24  Show Profile  Reply with Quote
I actually just figured this one out. I had to use the For XML() function to concatanante the rows together.
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.06 seconds. Powered By: Snitz Forums 2000