Importing Data from Excel to SQL table

%3CLINGO-SUB%20id%3D%22lingo-sub-319452%22%20slang%3D%22en-US%22%3EImporting%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-319452%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20getting%20truncation%20errors%20while%20importing%20Excel%20spreadsheet%20to%20SQL%20table.%20Not%20quite%20sure%20how%20to%20fix%20this.%20My%20column%20in%20SQL%20table%20is%20plenty%20long%20enough%20to%20hold%20the%20contents%20of%20column.%20Here%20are%20the%20errors%3A%3C%2FP%3E%3CP%3E%3CEM%3E%3CSTRONG%3EError%200xc020901c%3A%20Data%20Flow%20Task%201%3A%20There%20was%20an%20error%20with%20Source%20-%20Tickets%24.Outputs%5BExcel%20Source%20Output%5D.Columns%5BDescription%5D%20on%20Source%20-%20Tickets%24.Outputs%5BExcel%20Source%20Output%5D.%20The%20column%20status%20returned%20was%3A%20%22Text%20was%20truncated%20or%20one%20or%20more%20characters%20had%20no%20match%20in%20the%20target%20code%20page.%22.%3C%2FSTRONG%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CEM%3E%3CSTRONG%3EError%200xc020902a%3A%20Data%20Flow%20Task%201%3A%20The%20%22Source%20-%20Tickets%24.Outputs%5BExcel%20Source%20Output%5D.Columns%5BDescription%5D%22%20failed%20because%20truncation%20occurred%2C%20and%20the%20truncation%20row%20disposition%20on%20%22Source%20-%20Tickets%24.Outputs%5BExcel%20Source%20Output%5D.Columns%5BDescription%5D%22%20specifies%20failure%20on%20truncation.%20A%20truncation%20error%20occurred%20on%20the%20specified%20object%20of%20the%20specified%20component.%3C%2FSTRONG%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CEM%3E%3CSTRONG%3EError%200xc0047038%3A%20Data%20Flow%20Task%201%3A%20SSIS%20Error%20Code%20DTS_E_PRIMEOUTPUTFAILED.%20The%20PrimeOutput%20method%20on%20Source%20-%20Tickets%24%20returned%20error%20code%200xC020902A.%20The%20component%20returned%20a%20failure%20code%20when%20the%20pipeline%20engine%20called%20PrimeOutput().%20The%20meaning%20of%20the%20failure%20code%20is%20defined%20by%20the%20component%2C%20but%20the%20error%20is%20fatal%20and%20the%20pipeline%20stopped%20executing.%20There%20may%20be%20error%20messages%20posted%20before%20this%20with%20more%20information%20about%20the%20failure.%3C%2FSTRONG%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-327202%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-327202%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F268368%22%20target%3D%22_blank%22%3E%40Christian_McGhee%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F110080%22%20target%3D%22_blank%22%3E%40Pio%20Balistoy%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20doing%20a%20little%20further%20testing%2C%20I%20figured%20out%20that%20the%20SQL%20table%20column%20did%20not%20like%20the%20%3CSTRONG%3E'%3C%2FSTRONG%3E%20character%20in%20my%20Excel%20column.%20Is%20there%20an%20SQL%20Data%20Type%20that%20will%20accept%20the%20%3CSTRONG%3E'%3C%2FSTRONG%3E%20so%20I%20don't%20have%20to%20remove%20them%20all%20from%20Excel%3F%20Thank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-326532%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-326532%22%20slang%3D%22en-US%22%3E%3CP%3EAny%20other%20ideas%20on%20how%20to%20get%20this%20data%20imported.%20I%20have%20not%20found%20any%20other%20solutions%20via%20Googling%3F%20Thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-325252%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-325252%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F268368%22%20target%3D%22_blank%22%3E%40Christian_McGhee%3C%2FA%3E%26nbsp%3B%20%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F110080%22%20target%3D%22_blank%22%3E%40Pio%20Balistoy%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20your%20suggestion%2C%20saving%20as%20CSV%20and%20importing%20as%20a%20Flat%20File%20but%20still%20getting%20errors%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EError%200xc02020a1%3A%20Data%20Flow%20Task%201%3A%20Data%20conversion%20failed.%20The%20data%20conversion%20for%20column%20%22tech_comment%22%20returned%20status%20value%204%20and%20status%20text%20%22Text%20was%20truncated%20or%20one%20or%20more%20characters%20had%20no%20match%20in%20the%20target%20code%20page.%22.%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EError%200xc020902a%3A%20Data%20Flow%20Task%201%3A%20The%20%22Source%20-%20helpdesk2019_csv.Outputs%5BFlat%20File%20Source%20Output%5D.Columns%5Btech_comment%5D%22%20failed%20because%20truncation%20occurred%2C%20and%20the%20truncation%20row%20disposition%20on%20%22Source%20-%20helpdesk2019_csv.Outputs%5BFlat%20File%20Source%20Output%5D.Columns%5Btech_comment%5D%22%20specifies%20failure%20on%20truncation.%20A%20truncation%20error%20occurred%20on%20the%20specified%20object%20of%20the%20specified%20component.%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EError%200xc0202092%3A%20Data%20Flow%20Task%201%3A%20An%20error%20occurred%20while%20processing%20file%20%22%5C%5Cthunter-laptop%5Cusers%5Cthunter%5CDesktop%5Chelpdesk2019.csv%22%20on%20data%20row%202.%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EError%200xc0047038%3A%20Data%20Flow%20Task%201%3A%20SSIS%20Error%20Code%20DTS_E_PRIMEOUTPUTFAILED.%20The%20PrimeOutput%20method%20on%20Source%20-%20helpdesk2019_csv%20returned%20error%20code%200xC0202092.%20The%20component%20returned%20a%20failure%20code%20when%20the%20pipeline%20engine%20called%20PrimeOutput().%20The%20meaning%20of%20the%20failure%20code%20is%20defined%20by%20the%20component%2C%20but%20the%20error%20is%20fatal%20and%20the%20pipeline%20stopped%20executing.%20There%20may%20be%20error%20messages%20posted%20before%20this%20with%20more%20information%20about%20the%20failure.%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E(SQL%20Server%20Import%20and%20Export%20Wizard)%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-325225%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-325225%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHmm%2C%3C%2FP%3E%3CP%3ERather%20than%20trying%20to%20troubleshoot%20you%20Collation%20problem%20lets%20see%20if%20we%20can%20fix%20this%20another%20way.%20Try%20Saving%20the%20excel%20file%20to%20a%20.csv.%20From%20Excel%3A%20File%26gt%3BExport%26gt%3BChange%20File%20Type%26gt%3BSave%26nbsp%3BAs.%26nbsp%3BThen%20using%20the%20%22SQL%20server%20Import%20Export%20Wizard%22%20select%20as%20the%20%22Source%22%20a%20%22Flat%20File%20Source%22%20from%20the%20drop%20down%20list%20and%20browse%20to%20the%20location%20of%20your%20saved%26nbsp%3B.csv.%20Make%20sure%20when%20browsing%20you%20tell%20it%20to%20look%20for%20the%20.csv%20file%20extension%20because%20it%20defaults%20to%20.txt.%20Then%20as%20your%20destination%20select%20%22SQL%20Server%20Native%20Client%2011.0%22%20from%20the%20drop%20down%20list.%20After%20clicking%20Next%20you%26nbsp%3Bshould%20be%20able%20to%20edit%20the%20mappings%20and%20destination%20data%20types%20as%20desired.%20Other%20wise%20its%20a%20bit%20hard%20to%20trouble%20shoot%20without%20hands%20on%20access.%26nbsp%3BLet%20me%20know%20if%20this%20works%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F93329%22%20target%3D%22_blank%22%3E%40tim%3C%2FA%3E%20%40Pio%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-324956%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-324956%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F110080%22%20target%3D%22_blank%22%3E%40Pio%20Balistoy%3C%2FA%3E%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F268368%22%20target%3D%22_blank%22%3E%40Christian_McGhee%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again%20for%20your%20feedback%20and%20help!%20I%20have%20tried%20the%20Description%20column%20in%20my%20Excel%20as%20both%20Text%20and%20General%20but%20still%20does%20not%20work.%20My%20description%20column%20in%20SQL%20table%20is%20nvarchar(1500)%2C%20should%20I%20be%20using%20a%20different%20Data%20Type%20on%20the%20column%20in%20SQL%3F%20Or%20is%20there%20a%20better%20way%20to%20save%20my%20Excel%20spreadsheet%20before%20importing%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-324763%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-324763%22%20slang%3D%22en-US%22%3EAS%20Christian%20pointed%20out%2C%20it%20may%20not%20be%20an%20issue%20on%20the%20data%20type%20but%20on%20the%20collation.%20There%20is%20a%20character%20on%20the%20excel%20that%20is%20not%20recognized%20by%20the%20Collation%20of%20the%20database%2FInstance.%20You%20can%20check%20the%20Description%20column%20on%20the%20Ticket%20worksheet.%20You%20can%20workaround%20this%20by%20changing%20the%20column%2Ftable%2Fdatabase%20collation%20for%20the%20destination.%20Or%20re%20save%2Fimport%20the%20excel%20file%20to%20a%20compatible%20encoding.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-320813%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-320813%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F268368%22%20target%3D%22_blank%22%3E%40Christian_McGhee%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20do%20have%20all%20my%20columns%20set%20to%20nvarchar%20and%20still%20getting%20the%20truncation%20error.%20Any%20other%20ideas%3F%3C%2FP%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fi.gyazo.com%2F2e9539eea1bf166e933396df88c19c70.png%22%20border%3D%220%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-320795%22%20slang%3D%22en-US%22%3ERe%3A%20Importing%20Data%20from%20Excel%20to%20SQL%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-320795%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3BIt%20would%20seem%20that%20you%20have%20one%20or%20more%20characters%20that%20are%20not%20being%20recognized%20by%20the%20code%20page%20you%20are%20using.%26nbsp%3BChange%20data%20type%20for%20destination%20column%20to%20nvarchar(xx)%20Unicode.%20That%20should%20do%20it%20I%20suspect.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Super Contributor

I am getting truncation errors while importing Excel spreadsheet to SQL table. Not quite sure how to fix this. My column in SQL table is plenty long enough to hold the contents of column. Here are the errors:

Error 0xc020901c: Data Flow Task 1: There was an error with Source - Tickets$.Outputs[Excel Source Output].Columns[Description] on Source - Tickets$.Outputs[Excel Source Output]. The column status returned was: "Text was truncated or one or more characters had no match in the target code page.".
(SQL Server Import and Export Wizard)

Error 0xc020902a: Data Flow Task 1: The "Source - Tickets$.Outputs[Excel Source Output].Columns[Description]" failed because truncation occurred, and the truncation row disposition on "Source - Tickets$.Outputs[Excel Source Output].Columns[Description]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
(SQL Server Import and Export Wizard)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - Tickets$ returned error code 0xC020902A. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)

8 Replies

 It would seem that you have one or more characters that are not being recognized by the code page you are using. Change data type for destination column to nvarchar(xx) Unicode. That should do it I suspect.

 

@Christian_McGhee

 

I do have all my columns set to nvarchar and still getting the truncation error. Any other ideas?

AS Christian pointed out, it may not be an issue on the data type but on the collation. There is a character on the excel that is not recognized by the Collation of the database/Instance. You can check the Description column on the Ticket worksheet. You can workaround this by changing the column/table/database collation for the destination. Or re save/import the excel file to a compatible encoding.

@Pio Balistoy  @Christian_McGhee 

 

Thanks again for your feedback and help! I have tried the Description column in my Excel as both Text and General but still does not work. My description column in SQL table is nvarchar(1500), should I be using a different Data Type on the column in SQL? Or is there a better way to save my Excel spreadsheet before importing?

 

Hmm,

Rather than trying to troubleshoot you Collation problem lets see if we can fix this another way. Try Saving the excel file to a .csv. From Excel: File>Export>Change File Type>Save As. Then using the "SQL server Import Export Wizard" select as the "Source" a "Flat File Source" from the drop down list and browse to the location of your saved .csv. Make sure when browsing you tell it to look for the .csv file extension because it defaults to .txt. Then as your destination select "SQL Server Native Client 11.0" from the drop down list. After clicking Next you should be able to edit the mappings and destination data types as desired. Other wise its a bit hard to trouble shoot without hands on access. Let me know if this works

 

@tim @Pio

@Christian_McGhee   @Pio Balistoy 

 

I tried your suggestion, saving as CSV and importing as a Flat File but still getting errors:

Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "tech_comment" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
(SQL Server Import and Export Wizard)

Error 0xc020902a: Data Flow Task 1: The "Source - helpdesk2019_csv.Outputs[Flat File Source Output].Columns[tech_comment]" failed because truncation occurred, and the truncation row disposition on "Source - helpdesk2019_csv.Outputs[Flat File Source Output].Columns[tech_comment]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
(SQL Server Import and Export Wizard)

Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "\\thunter-laptop\users\thunter\Desktop\helpdesk2019.csv" on data row 2.
(SQL Server Import and Export Wizard)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - helpdesk2019_csv returned error code 0xC0202092. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)

Any other ideas on how to get this data imported. I have not found any other solutions via Googling? Thank you.

@Christian_McGhee @Pio Balistoy 

 

After doing a little further testing, I figured out that the SQL table column did not like the ' character in my Excel column. Is there an SQL Data Type that will accept the ' so I don't have to remove them all from Excel? Thank you!