Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Convert Row Data in 1 Field to Many Columns Expand / Collapse
Author
Message
Posted Wednesday, April 9, 2014 8:58 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:12 PM
Points: 13,441, Visits: 12,303
Japster (4/9/2014)
Hi,

thanks for the reply, for this exercise there will always be 7 serials per box.

However there is data in the table that has 42 serials in a box, will that cause a problem ?

Thanks


Nope. Look at the example I linked yesterday. It will show exactly how to do this kind of thing.


_______________________________________________________________

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
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1560007
Posted Wednesday, April 9, 2014 9:17 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, September 12, 2014 3:38 AM
Points: 338, Visits: 1,426
So this is your homework?
Post #1560019
Posted Wednesday, April 9, 2014 9:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, April 9, 2014 9:21 AM
Points: 5, Visits: 17
Sean Lange (4/9/2014)
Japster (4/9/2014)
Hi,

thanks for the reply, for this exercise there will always be 7 serials per box.

However there is data in the table that has 42 serials in a box, will that cause a problem ?

Thanks


Nope. Look at the example I linked yesterday. It will show exactly how to do this kind of thing.


Yes I looked at the link you provided yesterday and I still don't get it, sorry my SQL skills are weak
Post #1560025
Posted Wednesday, April 9, 2014 9:33 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:12 PM
Points: 13,441, Visits: 12,303
Japster (4/9/2014)
Sean Lange (4/9/2014)
Japster (4/9/2014)
Hi,

thanks for the reply, for this exercise there will always be 7 serials per box.

However there is data in the table that has 42 serials in a box, will that cause a problem ?

Thanks


Nope. Look at the example I linked yesterday. It will show exactly how to do this kind of thing.


Yes I looked at the link you provided yesterday and I still don't get it, sorry my SQL skills are weak


OK. Then I am not going to post the code because you need to understand any code that you use. Let's break this down into pieces to help you understand what is going on.

The first step was to create a cte to allow us to number the rows. Do you understand the cte I used? Did you understand why I did that?


_______________________________________________________________

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
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1560028
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse