With an Orders table (OrderID, date, customerID, status, etc) and an OrderDetails table (ParentID, itemID, quantity, price, etc), I would like to create a SQL Query that will export a CSV flat file with Order and OrderDetail rows interspersed. For instance, output might look like this ("H" and "D" indicate "Header" and "Detail" respectively.):
"H",2345,"6/1/09",856,"Shipped" "D",2345,52,1,1.50 "D",2345,92,2,3.25 "D",2345,74,1,9.99 "H",2346,"6/1/09",474,"Shipped" "D",2346,74,1,9.99 "D",2346,52,1,1.50
Not sure where to even start with this. Any ideas? TIA.