I have SQL database where I have Boxes and 6 or 4 bottle serials inside boxes. I to have these like
BoxID1, ItemCode, Batch, Netweight, Grossweight,Bottle1,Bottle2,Bottle3
BoxID2, ItemCode, Batch, Netweight, Grossweight,Bottle1,Bottle2,Bottle3
BoxID3, ItemCode, Batch, Netweight, Grossweight,Bottle1,Bottle2,Bottle3..... to get it exported to text file (one per boxId)
so basicly I need to have sql pivot vertical to horizontal or something like it but cannot
Can anyone advice? Thanks!
First, read the following article to help us help you in the future. Providing readily consumable test data will give your question a much better chance of being answered and a whole lot more quickly.
You're graphic is also pretty small and a bit difficult to read even after expanding it by clicking on it.
Getting to the problem as the problem is written the advice would be to either use the UNPIVOT operator or use CROSS APPLY with either a column based VALUES operator or a series of embedded SELECT/UNION ALLs to unpivot your data as desired.