Could someone please explain why I get the following errors? - sql

Data conversion failed. The data conversion for column "TIME PERIOD" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
Error: 0xC0209029 at Data Flow Task, Flat File Source [565]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "TIME PERIOD" (590)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "TIME PERIOD" (590)" 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.

I suggest importing flat files to staging tables (all text fields, no casting) then migrating them to your final table. Importing them without casting will sidestep errors like this, as long as your text fields are sufficiently long as to avoid truncation.
When you migrate the data in SSIS from staging to final table you can direct rows that error to an appropriate error output that you can use to isolate the problematic rows and decide how to handle them. Then you can fix and migrate those rows separately.
To my knowledge there's not an easy way to handle capturing problematic rows when casting on flat-file import in SSIS
You could change your SSIS to not fail the package on error, but then you'd have to dig for the problematic rows in the csv.

Related

SQL Import issues with large numeric values

I am facing issues when importing large data values into a pre-defined data table in SQL. Any value larger or equal to 100,000,000 (one hundred million) creates an error and fails upon import. A value of 99,999,999 is fine. Does anyone know what is going on and how to solve this, please?
Notes:
The data table I import data to is pre-defined; I can only append rows. The target column is defined as float(Null). The import wizard seems to set the data type to float automatically. I could not change it to numeric or decimal because a) I do not have the admin rights, and b) there is something funny with the source data when trying to import. But I cannot see anything to be off when looking at it in Excel; all values are numeric and the max length is only 11.
The files I use are in .csv format and many have more than 1 million rows. I tried splitting them up using Python and saving them in .xlsx format to put them through an Excel formatting step, but that did not help.
I am using the import wizard, SMSS v.18.12.1, and the SQL Server Native Client 11.0 of the import wizard.
The error message I get is:
`
Error 0xc02020c5: Data Flow Task 1: Data conversion failed while converting column "ColumnName" (42) to column "ColumnName" (148). The conversion returned status value 6 and status text "Conversion failed because the data value overflowed the specified type.".
(SQL Server Import and Export Wizard)
and
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[ColumnName]" failed because error code 0xC0209082 occurred, and the error row disposition on "Data Conversion 0 - 0.Outputs[Data Conversion Output].Columns[ColumnName]" 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)
`

SSIS Conversion Error - Visual Studio 2013

Currently I am working on two databases. Migrating information from an operational database to a datawarehouse with the well known Data Vault structure. However, it seems impossible for me to load data from the operational database to the data vault. I keep receiving to same errors over and over again.
I have checked multiple standard error creators:
COLLATE of both Database structures is the same;
No change in datatypes between operational and datawarehouse;
Removed and rewritten queries and databases multiple times.
Error output is in the next code block. Could one of you help me out here?
If needed i can provide a screenshot of the Visual Studio error screen. I have tried googling and searching this particular problem everywhere, but I do not seem to get it fixed.
Error: 0xC0202009 at Load SATT, SATT_DELIVERY_PRICE [439]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
Error: 0xC0202009 at Load SATT, SATT_DISTRICT [461]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
Error: 0xC0209029 at Load SATT, SATT_DISTRICT [461]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "SATT_DISTRICT.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "SATT_DISTRICT.Inputs[OLE DB 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.
Error: 0xC0047022 at Load SATT, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "SATT_DISTRICT" (461) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (474). 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.
Error: 0xC0202009 at Load SATT, SATT_EMPLOYEE [483]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
Error: 0xC02020C4 at Load SATT, CONSIGNMENT [2]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0209029 at Load SATT, SATT_EMPLOYEE [483]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "SATT_EMPLOYEE.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "SATT_EMPLOYEE.Inputs[OLE DB 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.
Error: 0xC0047038 at Load SATT, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on CONSIGNMENT returned error code 0xC02020C4. 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.
Error: 0xC0047022 at Load SATT, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "SATT_EMPLOYEE" (483) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (496). 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.
Error: 0xC0202009 at Load SATT, SATT_CUSTOMER [403]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
Error: 0xC0209029 at Load SATT, SATT_CUSTOMER [403]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "SATT_CUSTOMER.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "SATT_CUSTOMER.Inputs[OLE DB 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.
Error: 0xC0047022 at Load SATT, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "SATT_CUSTOMER" (403) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (416). 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.
Error: 0xC0209029 at Load SATT, SATT_DELIVERY_PRICE [439]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "SATT_DELIVERY_PRICE.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "SATT_DELIVERY_PRICE.Inputs[OLE DB 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.
Error: 0xC0047022 at Load SATT, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "SATT_DELIVERY_PRICE" (439) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (452). 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.
This is why there is no substitute for understanding teh meaning of your data and the meaning of error codes. You are trying to put data into a column where you have no data in the row for that field. This could be a problem of database design where the first database allows nulls and the one you are inserting to does not or it could be an incorrect query that thorugh a bad join or where condition is not getting teh right tdata to pass to the other database or it could be a problem of incorrect SSIS pacakge design causing the data to not correctly populate based on what the business rules should be. We can't tell that - only someone who has expertise in your system can.
I can give you an a example I ran across recently though where this type of thing happened. A pacakage that had been running correctly for months (and for multiple clients) was suddenly not working for only one client and the error was that the PK was null. This made no sense at all since the PK was generated in one table and passed to two related staging tables in an earlier step and it was a required field in the staging tables. The problem came because one of the tables did not have a record to match the data in the other table and the data set for the table it was failing on took the key from the table withouth the matching record and not the one that had a value. In this case the SSIS package was at fault and needed to be fixed.
Another way this happens is if the data is not a PK in the orginating table and is in a field that allows nulls. In this case you need to fix the data and you should fix the SSIS package to send that sort of data to an exception table. You should have been doing that as a matter of course anyway.
It is far easier to troubleshoot exceptions when you send the failed data to an exception table. It also means you can process the other data if your business rules would allow it. However, be careful of sending data to an exception table and never trying to fix those exceptions. If you have an exception table, someone should review it and try to make fixes for the problems at least weekly.
Or you could be pulling data from a query that needs adjustment. Suppose you had a case where all types of sales always included the customer id. Then the application was adjusted to let tehre be internal sales and in a fit of stupidity decided that internal customers did not have to have customer ids. Now suddenly a field you always had filled in is occasionally empty. Application devs rearely consider other things sucha as datawarehousing and reporting that might be affected by their decisions and often don't notify the BI devs who wook on these things when they make changes. So looking for what might have changed in the underlying data model is always a possibility to consider. In this case perhaps the internal orders are not needed for the data warehouse or if they are perhaps an fake cuastomer id like -1 can be attached in the dataflow if the underlying model cannot be changed.
The biggest problem I see with your package however is that you apparently don't understand what the errors mean (or even how to pull them out from a mess of information) or you would have known all this already. You need to start looking at the errors you get and learning through Google what they mean. Then you need to apply that meaning to the way your particular database and SSIS package are designed.
You need to develop a far better way to troublshoot, so you need to set up your SSIS pacakages with logging and exception tables and the things you will need to be able to capture the problem when it occurs.
There is no such thing as an SSIS package that will work prefectly 100% of the time. Data models change, people start entering data differntly than they used to, one bad data entry person can mess up a working SSIS pacakge by putting in values that no one ever considered. Or worse the data can in error and continue on to the next location blindly.
Error handling and trapping of the data that is being sent through the process is something every SSIS package should have because you will need it. You can't think of designing an SSIS package with the assumption that everything will remain the same. You need to know it will fail when it should, it will reject bad data and it will recognize when unexpected data happens. You need to understand that things will change over time and an SSIS package needs to be able to throw up a smoke signal when they do.
I have packages that fail because there are two few records in the import file. I have packages that send data to the exception table when I was expecting an integer and I got text and on an on and on. Most of my packages spend far more tasks on fixing data, sending unfixable data to the exceptions and handling errors than they do on the actual movement of data. This is one reason why I never design a package without staging tables. Far better to fail before you get to the final destination than to have to rollback a bunch of production tables. If you are not doing those things, you need to start.

BIDS Package Error's on Truncate while EXPORTING to flat file

I have a BIDS package. The final "Data Flow Task" exports a SQL table to Flat File. I receive a truncation error on this process. What would cause a truncation error while exporting to flat file? The error was occurring within the "OLE DB" element under the Data Flow tab for the "Data Flow Task".
I have set the column to ignore truncation errors and the export works fine.
I understand truncation errors. I understand why they would happen when you are importing data into a table. I do not understand why this would happen when outputting to a flat file.
This might be occurring for many reasons. Please make sure some of the steps listed below:
1) Check the source Data types that has to match with destination data type. If there are different it might through Truncation Error.
2) Check if there are blocks :- You can check this by creating Data viewer before the Destination and see the data come through.

Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column

I'm trying to insert a large CSV file (several gigs) into SQL Server, but once I go through the Import Wizard and finally try to import the file I get the following error report:
Executing (Error)
Messages
Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data
conversion for column ""Title"" 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 -
Train_csv.Outputs[Flat File Source Output].Columns["Title"]" failed
because truncation occurred, and the truncation row disposition on
"Source - Train_csv.Outputs[Flat File Source Output].Columns["Title"]"
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:\Train.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 - Train_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)
I created the table to insert the file into first, and I set each column to hold varchar(MAX), so I don't understand how I can still have this truncation issue. What am I doing wrong?
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 (You can select multiple columns and change them all at once).
This answer may not apply universally, but it fixed the occurrence of this error I was encountering when importing a small text file. The flat file provider was importing based on fixed 50-character text columns in the source, which was incorrect. No amount of remapping the destination columns affected the issue.
To solve the issue, in the "Choose a Data Source" for the flat-file provider, after selecting the file, a "Suggest Types.." button appears beneath the input column list. After hitting this button, even if no changes were made to the enusing dialog, the Flat File provider then re-queried the source .csv file and then correctly determined the lengths of the fields in the source file.
Once this was done, the import proceeded with no further issues.
I think its a bug, please apply the workaround and then try again: http://support.microsoft.com/kb/281517.
Also, go into Advanced tab, and confirm if Target columns length is Varchar(max).
The Advanced Editor did not resolve my issue, instead I was forced to edit dtsx-file through notepad (or your favorite text/xml editor) and manually replace values in attributes to
length="0" dataType="nText" (I'm using unicode)
Always make a backup of the dtsx-file before you edit in text/xml mode.
Running SQL Server 2008 R2
Goto Advanced tab----> data type of column---> Here change data type from DT_STR to DT_TEXT and column width 255. Now you can check it will work perfectly.
Issue:
The Jet OLE DB provider reads a registry key to determine how many rows are to be read to guess the type of the source column.
By default, the value for this key is 8. Hence, the provider scans the first 8 rows of the source data to determine the data types for the columns. If any field looks like text and the length of data is more than 255 characters, the column is typed as a memo field. So, if there is no data with a length greater than 255 characters in the first 8 rows of the source, Jet cannot accurately determine the nature of the data type.
As the first 8 row length of data in the exported sheet is less than 255 its considering the source length as VARCHAR(255) and unable to read data from the column having more length.
Fix:
The solution is just to sort the comment column in descending order.
In 2012 onwards we can update the values in Advance tab in the Import wizard.

Error importing to SQL Server 2008R2 from Excel 2010

I am using the SQL Server Import and Export Wizard to try to import a particular xlsx spreadsheet into an existing table in SQL. The existing table contains a sub-set of the columns in the spreadsheet and I am ignoring the many columns that don't match.
The spreadsheet has 123 columns and 238 lines of data.
Initially when I was importing the spreadsheet the wizard was hanging on 'Executing' and I had to kill the process. Something I have never come across before.
After copy and pasting the data into a new spreadsheet it is now coming up with the following error:
Error 0xc020901c: Data Flow Task 1: There was an error with output column "Confidentiality Clause Comments" (108) on output "Excel Source Output" (9). 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 "output column "Confidentiality Clause Comments" (108)" failed because truncation occurred, and the truncation row disposition on "output column "Confidentiality Clause Comments" (108)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
(SQL Server Import and Export Wizard)
What I am confused about it, the column "Confidentiality Clause Comments" is one of the columns being ignored - it is not being imported into the database!
I have tried setting "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet 4.0\Engines\Excel\TypeGuessRows" to both 0 and higher numbers like 238 and 1000 to increase the sample size. (Although the table does already exist with fields large enough for the data being imported). I also have the "On Truncation (global)" and "On Error (global)" set to Ignore (but this setting seems to be 'ignored').
I have also tried importing the data into a new table, and get the same truncation error message (but on different fields dependant on the data sort).
I thought about importing as a CSV file but there are embedded comma's in many of the fields and it completely messed the data up.
Any ideas on how to get data imported? I have spent over 3 hours on this already, and have got nowhere.
Thanks,Steve
Instead of CSV, you could save as Text (Tab delimited) (*.txt) - that way you won't encounter the comma problem.
Also, if you only need to do this once, and because the dataset is not exactly huge, I'd consider just copying from excel and pasting directly into sql server management studio.