3 messages in com.mysql.lists.win32Re: How to use T-SQL to copy data bet...
FromSent OnAttachments
ascll14 Nov 2006 04:45 
Brandon Schenz14 Nov 2006 05:26 
Bob Horrobin14 Nov 2006 11:56 
Subject:Re: How to use T-SQL to copy data between tables
From:Bob Horrobin (robe@virgin.net)
Date:11/14/2006 11:56:08 AM
List:com.mysql.lists.win32

You are trying to do a cross tab function. This could give you all sorts of problems if your orders have more than ten products.

I Assume that you can only have one invoice per order.

First job is to validate the data and resolve any issues there.

If this is a one off I would drop it into something like Excel that has cross tab capability (pivot tables) then, if you must, load it into your table from there.

If you need to repeat this frequently you need to write a stored procedure that will read your two existing tables joining on order number and sorted to invoice number. You can then construct each row for your new table on change of order number.

Good luck