goofyui
goofyui

Reputation: 3492

Export - Text File - SQL Database

SQL 2008 : Using SQL SSIS Package, I am exporting Excel Sheet to Text File and then Exporting to SQL Database. I decided to follow two steps of Export process as because of datatype mismatch between SQL Database and some of Excel Columns. When there is a mismatch in the Datatype, SSIS Package stops the Export Process but results as SSIS Package ran successfully.

To avoid partial import of Excel sheet, i decided to follow two steps of export. When different datatype of Excel Sheet goes to Text File, it reflect as String. When i am exporting back from Text file to SQL Database,it goes as STRING and again failing to export due to datatype mismatch.

Major Issue : If there is a mismatch in the Excel Sheet at nth row, Export stops at the nth row. Still, we get the output as Package Successful. How to fix the datatype mismatch of Excel Data Export to SQL Database ?

Upvotes: 0

Views: 822

Answers (1)

Marcus D
Marcus D

Reputation: 1144

You could approach it slightly differently as follows: read the excel spreadsheet in directly to one or more staging table(s) but force all columns to be VARCHAR/NVARCHAR columns. This will then enable you to read all rows into SQL without errors. Then create a second DFT to read from the staging table(s) into your correctly defined table(s)(correctly defined in terms of field type/size). You can build error logging into the second DFT to pump erroneous rows into an error table for later attention.

Upvotes: 2

Related Questions