SSIS Export to Excel Numbers Stored as Text

Like many DBA before me, I have battled SSIS Exports to Excel with valor and tenaciousness (word?). Sometimes I win, sometimes I lose (I think the score is SSIS 2 – Joe 5). I seem to remember having trouble exporting numbers to Excel in the past but it took me a while to figure it out again. So this time I am documenting it.

Assumes you have an existing package you are modifying. Works however with a new package destination as well.

  1. Right Click on your Excel Destination and click Edit
  2. Hit the New Button next to the Name of the Excel Sheet
  3. You should get a Create Table Window. Copy this CREATE statement to your favorite Text Editor
  4. Cancel out of the Excel Destination edit
  5. Find your actual Excel Destination file on the OS and delete it
  6. Now if you need to make changes to the worksheet you can using your text editor. Get the CREATE table setup like you want it. Make sure you define your number columns as Type Long and your Text Columns as LongText
  7. Right Click on your Excel Destination and click Edit again.
  8. You can now either use the CREATE TABLE that is generated by SSIS or you can use your CREATE TABLE Script you modified in Step 6
  9. If you have added new columns manually to your CREATE Table statement you will need to go to your source and fix that. You may get some validation errors that you will need to resolve.
  10. Click OK on the Create and then you should see your Sheet name in the drop down box.

This method will also remove any extra sheets in your Worksheet (Sheet1, 2, 3) and will create a new sheet based on the name in the CREATE TABLE Script.

Advertisements