1
votes

I want to update a table using data from an excel sheet. My excel file have just two columns, one with a uniqueidentifier and the other with a reference. I tried to use the OPENROWSET command to update my table, but the database have a security property that doesn't allows me to do it.

My idea now is to create a new table in my database with those two columns, and update the data in my table later. To create the data in my database I tried to use the Import Wizard in SQL Server but when I tried to do it, I got the following messages:

Error 0xc020901c: Data Flow Task 1: There was an error with Source - Sheet1$.Outputs[Excel Source Output].Columns[PST_WSI_RefDes] on Source - Sheet1$.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 - Sheet1$.Outputs[Excel Source Output].Columns[PST_WSI_RefDes]" failed because truncation occurred, and the truncation row disposition on "Source - Sheet1$.Outputs[Excel Source Output].Columns[PST_WSI_RefDes]" 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 - Sheet1$ 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)

I know those messages refer to my data, but my excel file have 12k lines and I don't know what line has problem.

How to investigate what line has problem? Or, is there other ways to import data from excel?

More information:

Sample of data I'm trying to import

C7 (OP1 to OP12), C10 (OP1 to OP12), C3 (IP1 to IP16), C6 (OP1 to OP12), C10, C11, C12, C45, C49, C50, C14 (OP1 to OP12), C5 (OP1 to OP12), C9 (OP1 to OP12), C15 (OP1 to OP12), C51, C52, C54, C55

Max size of the field: 1303 characters.

Import table format: I've tried two configurations:

1 - uniqueidentifier and nvarchar(2000)

2 - nvarchar(200) and nvarchar(2000)

2
This is the method I tried to use to import the data, and I got the messages that you can verify in my question. - Iohann Oro
Just tried. Same error messages appear. - Iohann Oro
In SQL Server Import and Export Wizard you can adjust the source data types in the Advanced tab (these become the data types of the output if creating a new table, but otherwise are just used for handling the source data). The data types are annoyingly different than those in MS SQL, instead of VARCHAR(255) it's DT_STR and the output column width can be set to 255. For VARCHAR(MAX) it's DT_TEXT. So, on the Data Source selection, in the Advanced tab, change the data type of any offending columns from DT_STR to DT_TEXT. - Vikram

2 Answers

0
votes

Try to use Excel2MySQL, It saved me lots of headaches..

0
votes

I believe it does, You can download it and try out, is free until you want to pay for extras features..