Importing data from worksheet into SQL Server - sql-server

I am trying to import data from MS Excel (Pro Plus 2013) to SQL Server 2014. Every time I attempt to do so I get the errors below. The columns in the the table are set to nvarchar(50) while in Excel none of the columns have more than 30 characters. I have tried recreating the Excel spreadsheet over and over again, just to be sure I am doing everything right. I just can't get the data to import.
These are the errors I receive:
Validating (Error) Messages:
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "Agent_First_Name" with a length of 255 to database column "Agent_First_Name" with a length of 50.(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "Agent_Last_Name" with a length of 255 to database column "Agent_Last_Name" with a length of 50.(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "Agent_Email" with a length of 255 to database column "Agent_Email" with a length of 50.(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "Agent_Extension" with a length of 255 to database column "Agent_Extension" with a length of 4.(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "Agent_Cell_Phone" with a length of 255 to database column "Agent_Cell_Phone" with a length of 10.(SQL Server Import and Export Wizard)
Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column "Agent_ID".(SQL Server Import and Export Wizard)
Error 0xc0202045: Data Flow Task 1: Column metadata validation failed.(SQL Server Import and Export Wizard)
Error 0xc004706b: Data Flow Task 1: "Destination - tableAgents" failed validation and returned validation status "VS_ISBROKEN".(SQL Server Import and Export Wizard)
Error 0xc004700c: Data Flow Task 1: One or more component failed validation.(SQL Server Import and Export Wizard)
Error 0xc0024107: Data Flow Task 1: There were errors during task validation.(SQL Server Import and Export Wizard)

It looks like you're trying to import into an existing table. I would recommend starting with importing the data into a new table (for example, "tmpAgent" -- and you can delete this table later). Allow SQL Server to pick the tables size of the import, or you can set the size in the "Edit mappings" section of the import.
After you have imported the data into a new table, then create a query to move it into your Agent table.

I encountered the same error message.
Turns out I had a rogue cluster of merged cells in the excel file. I un-merged those cells, re-tried the import, and all my data were successfully imported to the excel file.

Related

Import Large Cities Text File into SQL server

I'm trying to import Text file for cities name into SQL server 2012. The file is 1.45 GB, I'm using SQL Server Import and Export Wizard to do the job but each time I get this error:
Copying to [dbo].[worldcitiespop] (Error)
Messages
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "City" 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 - worldcitiespop_txt.Outputs[Flat File Source Output].Columns[City]" failed because truncation occurred, and the truncation row disposition on "Source - worldcitiespop_txt.Outputs[Flat File Source Output].Columns[City]" 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 "C:\Users\elsho\Downloads\worldcitiespop.txt\worldcitiespop.txt" on data row 114091.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - worldcitiespop_txt 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)
I changed the Table fields size to the text type to avoid data length problem but this did not help,please advise.
Thanks
I strongly recommend that you use a staging table. Import the table into a staging table with wide nvarchar() text fields.
If you cannot do this successfully, then the data file itself is probably corrupted.
After you have loaded into the staging table, insert the data (with appropriate conversions) into the final form (and then build indexes). It is much easier to find such problems when the data is already in a table than when trying to import it frustratingly over and over again.

DTS Import failing

I have a spreadsheet. It contains company information such as name, address, phone, email, etc. All I want to do is a flat import into SQL into a table it can create so I can do some processing on it. I'm just using MS SQL Import Wizard. I'm not using BCP.
It gets all the way to the end and gives me this error:
Blockquote
Operation stopped...
Initializing Data Flow Task (Success)
Initializing Connections (Success)
Setting SQL Command (Success)
Setting Source Connection (Success)
Setting Destination Connection (Success)
Validating (Success)
Messages
Warning 0x80049304: Data Flow Task 1: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available. To resolve, run this package as an administrator, or on the system's console.
(SQL Server Import and Export Wizard)
Prepare for Execute (Success)
Pre-execute (Success)
Executing (Error)
Messages
Error 0xc020901c: Data Flow Task 1: There was an error with Source - crm_company$.Outputs[Excel Source Output].Columns[Directions] on Source - crm_company$.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 - crm_company$.Outputs[Excel Source Output].Columns[Directions]" failed because truncation occurred, and the truncation row disposition on "Source - crm_company$.Outputs[Excel Source Output].Columns[Directions]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
(SQL Server Import and Export Wizard)
Copying to [dbo].[crm_company] (Stopped)
Messages
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - crm_company$ 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)
Post-execute (Success)
Messages
Information 0x4004300b: Data Flow Task 1: "Destination - crm_company" wrote 469 rows.
(SQL Server Import and Export Wizard)
Blockquote
First of all, I have told DTS to ignore any truncation errors. The source fields are either int or nvarchar. I edit the mappings and force it to be int instead of float for the required columns. I have set the default column size to 510 from 255. For 2 columns, Directions and Notes, it has decided that the Directions is nvarchar and the Notes is nvarchar(max). I override the Directions one so that it is treated as nvarchar(max) and I can see that in the table it creates after it runs. However, when it runs it fails EVERY TIME with the above error.
I just want this data into a table. That's all. If I specify a table manually first and import, it still errors. The longest text in Directions is 978 characters long so it is hardly huge. I don't care if it truncates, I just don't want it to stop when it feels it needs to. There are 16000 rows importing and only 470 get imported before it fails.
I don't know which row fails it in the source file because strangely, DTS is not pulling the data in, in the order it is in, in the spreadsheet. Go figure. I tried overriding DTS's stupid attemtps at deciding what the column formats are by sticking 20 rows of text data in, but that still fails.
Suggestions:
If you have Visual Studio BI then develop a SSIS pack and:
1.) Try adding a branch for failed lines to redirect those. You can do that by adding a route with the red line from the excel source. After running the package, you can some analysis on the successful and failed lines.
2.) Important thing is what type of connection do you use for the SQL Server. I have a lot of issues with native SQL Client so I prefer to use ADO.NET or OLE DB connection types.
With the Wizard:
3.) Try to use type conversion
4.) Save the file to TXT then do the ETL.
I tried many things to get around this and found it alot easier to import the spreadsheet into Access and then import Access to SQL. Job done in 5 minutes.

Postgresql to Sql Server 2008 Table Transfer

I'm using postgresql (Pgadmin Version 1.18.0), i export three(I need only 3 tables) table(Contains Online Transaction information) data's into csv format using the query
copy to 'D:\orders\new\users.csv' DELIMITER ';' CSV HEADER
I got perfect result using the query. Now i open the ssms(Sql Server 2008) and using the Import and Export data option i import the users.csv file to sql server 2012 by using "Flat File Service Data Source". at last while i click the Finish Button it throws the following error Messages
--Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for
column "address" 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 - users_csv.Outputs[Flat File Source
Output].Columns[address]" failed because truncation occurred, and the truncation row
disposition on "Source - users_csv.Outputs[Flat File Source Output].Columns[address]"
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 - users_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)
Please help me out. Sorry if it's vague.
Thanks in Anticipation.
Regards,
Keerthi
Your data's size exceeds the field size. Extend the size of your address field in the target table. If you still get the error, check the "Advanced" Option in the Import and Export Wizard. You can set the OutputColumnWidth for each column there.

Importing xsl into SQL Server table

I'm trying to import an xsl spreadsheet file into a SQL server table using the SQL Server export and import wizard. However, it failed to import and returned following messages:
Validation:
Validating (Warning)
Messages
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "ObjectName" with a length of 255 to database column "ObjectName" with a length of 31.
(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "ShortDescription" with a length of 255 to database column "ShortDescription" with a length of 75.
(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "ObjectName" with a length of 255 to database column "ObjectName" with a length of 31.
(SQL Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to inserting data from data flow column "ShortDescription" with a length of 255 to database column "ShortDescription" with a length of 75.
(SQL Server Import and Export Wizard)
Warning 0x80049304: Data Flow Task 1: Warning: Could not open global shared memory to communicate with performance DLL; data flow performance counters are not available. To resolve, run this package as an administrator, or on the system's console.
(SQL Server Import and Export Wizard)
While copying:
Copying to [dbo].[tblReports] (Error)
Messages
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Cannot insert duplicate key row in object 'dbo.tblReports' with unique index 'tblReports$SheetName'. The duplicate key value is ().".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Destination - tblReports.Inputs[Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "Destination - tblReports.Inputs[Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Destination - tblReports" (56) failed with error code 0xC0209029 while processing input "Destination Input" (69). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
How can I get this working?
For these two warnings:
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to
inserting data from data flow column "ShortDescription" with a length
of 255 to database column "ShortDescription" with a length of 75. (SQL
Server Import and Export Wizard)
Warning 0x802092a7: Data Flow Task 1: Truncation may occur due to
inserting data from data flow column "ObjectName" with a length of 255
to database column "ObjectName" with a length of 31. (SQL Server
Import and Export Wizard)
You should increase the column size because it looks like you have data that isn't falling within the constraints of the column.

Failed importing file in SQL Server Managment studio

In SQL Server Management Studio I exported a table from one database to an .xslx file, then imported it to another database on a different server. It failed to import and gave the following details:
Validating (Error)
Messages
• Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column "QuestionID".
(SQL Server Import and Export Wizard)
• Error 0xc0202045: Data Flow Task 1: Column metadata validation failed.
(SQL Server Import and Export Wizard)
• Error 0xc004706b: Data Flow Task 1: "component "Destination - HJFast_Track" (47)" failed validation and returned validation status "VS_ISBROKEN".
(SQL Server Import and Export Wizard)
• Error 0xc004700c: Data Flow Task 1: One or more component failed validation.
(SQL Server Import and Export Wizard)
Error 0xc0024107: Data Flow Task 1: There were errors during task validation.
(SQL Server Import and Export Wizard)
My best guess is that QuestionID is an auto-incrementing identity field. In order to insert values into that column you'll need to specify.
SET IDENTITY_INSERT YourTable ON
Your other option if that field is an auto-increment identity is leave it out of the import/export and let the sql engine generate keys like it would for any other insert.
Without having the schema of your table in front of me a guess is as good as I can offer.
If you update your question with the structure of the table your trying to insert that might give other clues. For example, if QuestionID is a guid or something.

Resources