I have the following SELECT statement in my SSIS 2008 OLE DB source:
SELECT dbo.Inventory.VendorFullSKU AS SKU
, Product.Name AS 'Title'
, dbo.ProductVariant.Price
, dbo.ProductVariant.SalePrice
, dbo.Inventory.Color AS Meta1
, dbo.Inventory.[Size] AS Meta2
FROM dbo.Inventory
INNER JOIN dbo.ProductVariant
ON dbo.Inventory.VariantID = ProductVariant.VariantID
INNER JOIN dbo.Product ON ProductVariant.ProductID = Product.ProductID
WHERE (dbo.Inventory.VendorFullSKU <> N'')
ORDER BY SKU
After running the package, my resulting flat file is not sequenced in the order I expect it to. There are no transformations being done to the data.
The flat file contains the columns in the below mentioned order.
Price, Title .. followed by other fields
However, I want the columns to be in this order within the flat file as defined in the query.
SKU, Title, Price, SalesPrice, Meta1, Meta2
How do I ensure that the fields in the flat file are sequenced the same as my select statement above?
You have to redefine the column order on Flat File Connection Manager Editor.
Assuming that your flat file connection manager is defined as
FILE_Itemsat the bottom of the package on theConnection Managerstab.Double-click the connection manager
FILE_Itemsto openFlat File Connection Manager Editor. ClickAdvancedtab page.To generate the files as per the query, the columns should be defined in the
ordershown below. If the columns are not in this order, then the generated flat file will not match your requirements.You
cannotrearrange the order of the columns because there are no options likemove upormove downbut you canAdd/Deletethem to modify the order according to your preference using the buttonsNewandDeletedisplayed below.New button also has options like
Insert BeforeandInsert After.Caution:
Make sure that you also set the correct data types and other properties appropriately when rearranging the columns.