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

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Concatenate Multiple Rows into Multiple Cells

Author  Topic 

davidhydro
Starting Member

4 Posts

Posted - 2014-09-30 : 04:45:54
Hi,

I have been set a task of updating multiple rows on our companies price list, with several breaks to be a single row with multiple breaks. Currently data layout is this..

Item No_ Description Unit Price Minimum Quantity
12345 Plastic Pot 0.15 1
12345 Plastic Pot 0.12 100
12345 Plastic Pot 0.10 1000

What I would like to achieve is to have one entry for 12345 with the multiple prices and quantities part of the same record like so..

Item No_ Description UP MQ UP MQ UP MQ
12345 Plastic Pot 0.15 1 0.12 100 0.10 1000

Any assistance is appreciated!

sunder.bugatha
Yak Posting Veteran

66 Posts

Posted - 2014-09-30 : 06:22:21
You can do it using Common Table Expressions CTE. I am unable to paste the code here it is throwing some network error when i try to submit

Hema Sunder
Go to Top of Page
   

- Advertisement -