SSIS Foreach loop error on CSV files - sql-server

Right, so I have a foreach loop with a data flow inside going through a group of files with all the exact same format. This changes a few things with a derived column which is all getting dumped into a SQL Server Database which will become my staging table.
The problem is that some files throw up an error even though the files are all formatted identically, the error is always around the date. It will go through 4 files with no problem and then on the 5th file it stops working.
What am I trying to do?
I want to get a whole load of files with the same format and put the data from within into an SQL database while changing some formats.
What have I tried to do?
I tried to reformat the date to be dd/mm/yyyy which is the format I want the date to have anyway.
The reformatting worked but then on the same file that had errors before it came up with a type cast error.
This is the error I get:
[OLE DB Destination [59]] Error: 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: "Invalid character value for cast specification".
[OLE DB Destination [59]] Error: There was an error with OLE DB Destination.Inputs[OLE DB Destination Input].Columns[Amount] on OLE DB Destination.Inputs[OLE DB Destination Input]. The column status returned was: "The value could not be converted because of a potential loss of data.".
[OLE DB Destination [59]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE DB Destination.Inputs[OLE DB Destination Input]" failed because error code 0xC0209077 occurred, and the error row disposition on "OLE DB Destination.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.
*[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE DB Destination" (59) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (72). 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.
*
It's happened before and I got around it by creating a new foreach loop to handle the new files with the new format (I could not see any change in the format but did it to continue).
This is the format for the Data Flow:
This is the image of the Derived Column
Any help would be greatly appreciated! if you need me to clarify anything just let me know.

Your columns appear to be in different orders. I replaced the tabs with pipes and got the following:
Working:
Staffordshire County Council|Staffordshire County Council Other|247 Cars Willenhall Ltd 15/06/2017|1126.97|Transport - Escorts|Transport - Escorts|opendatacommunities.org/id/county-council/staffordsh‌​ire
Not Working:
Staffordshire County Council|Childrens Services SEND|247 Cars Willenhall Ltd|273.42|06/07/2017|Transport - Escorts|Transport - Escorts opendatacommunities.org/id/county-council/staffordsh‌​ire
In the first one the date is on the other side of the amount, and appears to be included in the "247 Cars Willenhall Ltd" string.
If you enable the Data Viewer by right-clicking the arrow between the last two components and selecting the option, you'll get a clear view of how this is affecting your data flow (while running/debugging the package).

Related

Converting VARCHAR to DATE in SSIS

I have a data flow task in a SSIS package that loads data into a table from a flat file.
In the source data, there is a date column in the format DD/MM/YYYY, and I am trying to convert it to YYYY-MM-DD and convert it to a date. The expression in my Derived Column task is:
(DT_DATE)(SUBSTRING(SaleDate,7,4) + "-" + SUBSTRING(SaleDate,4,2) + "-" + SUBSTRING(SaleDate,1,2))
However this task fails with the below errors:
Error: 0xC0049064 at Load into Staging, Derived Column [2]: An error occurred while attempting to perform a type cast.
Error: 0xC0209029 at Load into Staging, Derived Column [2]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Derived Column" failed because error code 0xC0049064 occurred, and the error row disposition on "Derived Column.Outputs[Derived Column Output].Columns[SaleDate2]" 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 into Staging, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Derived Column" (2) failed with error code 0xC0209029 while processing input "Derived Column Input" (3). 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: 0xC02020C4 at Load into Staging, Flat File Source [12]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0047038 at Load into Staging, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Flat File Source 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.
Here is my expression editor:
I understand that this is probably quite a common issue but in searching for an answer I've not found anything that helps.
Have I missed something obvious?
I found the issue eventually myself, after attaching a data viewer to the derived column task, I realised that the date column had double quotes in the source file. I adjusted my SUBSTRING parameters to compensate and the import is working now.

SSIS Insert Data After Aggregate (Group By) with new Unique key

I have the Contoso Dataset of Microsoft. My goal is from this dataset which is a flat file, to fill tables on my database.
More specific the flat file contains three columns like these:
CurrencyLabel
CurrencyName
CurrencyDescription
My goal is to remove duplicates and insert the unique results in my table that have these columns
1. CurrencyKey
2. CurrencyLabel
3. CurrencyName
4. CurrencyDescription
The CurrencyKey column is the primary key of the table and it should be filled automatically with new keys of the results on SSIS.
At SSIS, i have made a control flow which contains the data flow.
In the data flow I have the flat file source, then aggregate with group by
with all columnns (CurrencyLabel, CurrencyName,CurrencyDescription ) and then I Have set the ole db destination to my table.
The goal is to fill all my four columns and the target is to increase the CurrencyKey from the aggregate.
The columns of the flat files and the first two rows:
OnlineSalesKey|SalesQuantity|SalesAmount|TotalCost|UnitCost|UnitPrice|CustomerLabel|Title|FirstName|MiddleName|LastName|BirthDate|MaritalStatus|Gender|EmailAddress|YearlyIncome|TotalChildren|NumberChildrenAtHome|Education|Occupation|HouseOwnerFlag|NumberCarsOwned|Phone|CurrencyLabel|CurrencyName|CurrencyDescription|IsWorkDay|IsHoliday|HolidayName|EuropeSeason|NorthAmericaSeason|AsiaSeason|ProductLabel|ProductName|ProductDescription|Manufacturer|BrandName|ColorName|Size|Weight|ProductCategoryLabel|ProductCategoryName|ProductCategoryDescription|StoreManager|StoreType|StoreName|StoreDescription|Status|OpenDate|CloseDate|StorePhone|StoreFax|Customer_address|store_address
19609697|1|313.52|180.22|180.22|391.9|18157||Isabella||Hall|1953-03-06|S|F|isabella80#adventure-works.com|90000|3|2|Partial College|Professional|1|1|1 (11) 500 555-0181|001|USD|US Dollar|WorkDay|0|None|Holiday|Spring/Back to Business|Holiday|0402095|Fabrikam SLR Camera M150 Orange|Digital camera ñ SLR, 5.2 in x 2.8 in x 3.7 in, 19.2 oz|Fabrikam, Inc.|Fabrikam|Orange|3.5 x 5 x 3.3 |5.25|04|Cameras and camcorders |Cameras and camcorders |246|Online|Contoso Europe Online Store|Contoso Europe Online Store|On|2004-09-03 00:00:00||731-555-0117|731-555-0117|Bundesallee 4422|Downtown Berlin, Germany
19609733|1|166.4|95.65|95.65|208|14866||Hailey|R|Peterson|1970-10-21|S|F|hailey14#adventure-works.com|40000|2|2|Partial College|Clerical|1|2|1 (11) 500 555-0123|001|USD|US Dollar|WorkDay|0|None|Holiday|Spring/Back to Business|Holiday|0504005|The Phone Company Smart phones 160x160 M26 Black|Smart phones 160x160, AC adapter, stylus, protective cover, installation CD-ROM, application manual|The Phone Company|The Phone Company|Black|4.5 x 3.1 x 0.6|4.5999999999999996|05|Cell phones|Cell phones|246|Online|Contoso Europe Online Store|Contoso Europe Online Store|On|2004-09-03 00:00:00||731-555-0117|731-555-0117|Pflugstr 24|Downtown Berlin, Germany
You can see that the fields are
001|USD|US Dollar
1. CurrencyLabel
2. CurrencyName
3. CurrencyDescription
My table
My data flow
Aggregate by group by
Mappings on OLE DB DESTINATION
Right now nothing seems to be written in my table and there is error by this this output:
SSIS package
Information: 0x4004300A at Fill Currency Table, SSIS.Pipeline:
Validation phase is beginning.
Information: 0x4004300A at Fill Currency Table, SSIS.Pipeline:
Validation phase is beginning.
Warning: 0x80049304 at Fill Currency Table, SSIS.Pipeline: 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.
Information: 0x40043006 at Fill Currency Table, SSIS.Pipeline: Prepare
for Execute phase is beginning.
Information: 0x40043007 at Fill Currency Table, SSIS.Pipeline: Pre-
Execute phase is beginning.
Information: 0x402090DC at Fill Currency Table, Flat File Source [30]:
The processing of file "C:\Users\george\Desktop\Data_201813_10M.txt"
has started.
Information: 0x4004300C at Fill Currency Table, SSIS.Pipeline: Execute
phase is beginning.
Information: 0x402090DE at Fill Currency Table, Flat File Source [30]:
The total number of data rows processed for file
"C:\Users\george\Desktop\Data_201813_10M.txt" is 10000001.
Error: 0xC0202009 at Fill Currency Table, OLE DB Destination [102]:
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: "The statement has been
terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native
Client 11.0" Hresult: 0x80004005 Description: "Cannot insert the
value NULL into column 'CurrencyKey', table
'DataWarehouse.dbo.DimCurrency'; column does not allow nulls. INSERT
fails.".
Error: 0xC0209029 at Fill Currency Table, OLE DB Destination [102]:
SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE DB
Destination.Inputs[OLE DB Destination Input]" failed because error code
0xC020907B occurred, and the error row disposition on "OLE DB
Destination.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 Fill Currency Table, SSIS.Pipeline: SSIS Error
Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component
"OLE DB Destination" (102) failed with error code 0xC0209029 while
processing input "OLE DB Destination Input" (115). 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.
Information: 0x40043008 at Fill Currency Table, SSIS.Pipeline: Post
Execute phase is beginning.
Information: 0x402090DD at Fill Currency Table, Flat File Source [30]:
The processing of file "C:\Users\george\Desktop\Data_201813_10M.txt"
has ended.
Information: 0x4004300B at Fill Currency Table, SSIS.Pipeline: "OLE DB
Destination" wrote 1 rows.
Information: 0x40043009 at Fill Currency Table, SSIS.Pipeline: Cleanup
phase is beginning.
Task failed: Fill Currency Table
Warning: 0x80019002 at DataWarehouse2018: SSIS Warning Code
DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but
the number of errors raised (3) reached the maximum allowed (1);
resulting in failure. This occurs when the number of errors reaches the
number specified in MaximumErrorCount. Change the MaximumErrorCount or
fix the errors.
SSIS package
Any idea?
Thank you

SSIS Destination Insert Error

PACKAGE DESCRIPTION: I use a Source from One database do a lookup to get a surrogate geography key then another to check if the customer exists, if not insert the row if so update the row...
PROBLEM: I am unable to insert approximately 700,000 rows.
PROBLEM DESCRIPTION: I have looked at this for a long, long time now using data viewer, outputting to flat files and cannot find the cause of my issues.
From the below errors, research and checking through SSIS I have drawn a blank.
Error: 0xC0209029 at DimCustomer, Dw_DimCustomer [2]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Dw_DimCustomer.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "Dw_DimCustomer.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 DimCustomer, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Dw_DimCustomer" (2) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (15). 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: 0xC02020C4 at DimCustomer, SQL_Customer [154]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0047038 at DimCustomer, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on SQL_Customer 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.
WORK DONE :
I've checked all formats match and that no truncation will occur.
Checked all lookups are working correctly.
Dropped my destination database (I'm in a test environment don't worry) and recreated it.
I've checked that all the correct columns are showing the correct data in the correct format between tasks.
I've checked the only error is coming from the final OLE DB destination output (which it is).
I am unsure where to go, as ever the answer is StackOverflow.
Any pointers or ideas or help would be welcomed with open arms.
From the image you attached i think that you are using SSIS 2012 or higher, After searching there are many issue that cause this problem.
You can test the following things:
First
if your server operationg system is 64-bit try running your ssis package in 64bit runtime. you can follow this link for more details.
Second
Try replacing OLEDB Destination with a SQL server Destination and set the TIME OUT to higher value (for ex : 500)
Thrird
On you OLEDB Destination try to uncheck Check Constraints checkbox (The error may be caused by a constraints)
References
First workaround
SSIS ERROR: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020
Second Workaround
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8a3558df-221a-45e6-8e08-c23c987c12a9/error-the-attempt-to-add-a-row-to-the-data-flow-task-buffer-failed-with-error-code-0xc0047020?forum=sqlintegrationservices
Additional Info
I think that this is the main Error message that you can search for it (if there is no error message received from your package) if my answer didn't solved it:
The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020
Hope it helps
Go to DimCustomer Properties:
Make BufferMaxRows to 100. This might increase the execution time for the package as it will transfer only 100 row at a time using a less RAM at that instance.
If this doesnt work:
You can create go for For-loop. Adding this same inside a For-loop appdeing 100 rows everytime it runs. You can found the loop execution by dividing the total count by 100. This will definitely help you!
This error occured when data is damaged before the data reaches the data flow destination. Data flow find unexpectly , null or blank or empty values you should to recreate your source data basese with healthy backup .

Error In SSIS on insert - String or binary data would be truncated

I have an error in my ssis pakage that I don't understand it:
Error: 0xC0202009 at InsertStudent, InsertStudent [303]: SSIS Error
Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code:
0x80040E57. An OLE DB record is available. Source: "Microsoft SQL
Server Native Client 11.0" Hresult: 0x80040E57 Description: "The
statement has been terminated.". An OLE DB record is available.
Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E57
Description: "String or binary data would be truncated.".
Error: 0xC0209029 at InsertStudent, InsertStudent [303]: SSIS Error
Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The
"InsertStudent.Inputs[OLE DB Command Input]" failed because error code
0xC020906E occurred, and the error row disposition on
"InsertStudent.Inputs[OLE DB Command 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 InsertStudent, SSIS.Pipeline: SSIS Error Code
DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component
"InsertStudent" (303) failed with error code 0xC0209029 while
processing input "OLE DB Command Input" (308). 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: 0xC0047022 at InsertStudent, SSIS.Pipeline: SSIS Error Code
DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Merge
Join" (406) failed with error code 0xC0047020 while processing input
"Merge Join Left Input" (411). 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.
One of your is getting an input value that is larger (in size) than what the column size is, as defined in your database table.
It's unfortunate that the error message does not also give you the name of the offending column. I think you are stuck with troubleshooting this the hard way, by looking at the values column by column until Microsoft fixes the error message
See Microsoft Connect: Please fix the "String or binary data would be truncated" message to give the column name
...and all the commentary on
Why isn't “String or Binary data would be truncated” a more descriptive error?
Check the component connected to OLE DB Command transformation and the left input of MERGE JOIN transformation, the size of the input string from that component is larger than the column size and therefore data truncation error happened here.
The solution would be to fix the data length from that component or to change the target table structure (enlarge the column size).
In my case this error connected with different length of columns in your DB. For example if you create Source DB you need to be sure that each column have sufficient maximum length and you don't put largest values (too long values) into this column.
So unfortunately SSIS don't specify the problematic column, and you need to find it by yourself or enlarge maximum length of every column.

SSIS: data types just don't get converted from string

That's my first experience in SSIS and I'm just going nuts: NOTHING WORKS.
(Don't be afraid of big post: most is just errors output.)
I've got two MS SQL DBs with same fields and I have to transfer from first one, where everything is in nvarchar(32) aka DT_WSTR, into second one, where types are different.
Data and its examples:
"Timestamp" is "datetime2(7)" in destination, and source looks like ISO 8601: 2013-12-19T00:00:00.000
"Value" is "real" numbers with scientific notation, test examples are: 17e+10, 17.14, 17.14e+5, 1715E+4, 1714
And four columns with just different ints (bigint, bigint, tinyint, int).
Now for what I've tried (warning for lots of quotations):
Derived Column. I used casts like "(DT_DBTIMESTAMP2,7)time" and "(DT_R4)value". Perhaps I'm using wrong types, but I strongly doubt: I googled it like a lot and most articles (like this) tells that I'm right.
Error: 0xC0049064 at Import from ODS to DWH, Derived Column [2]: An error occurred while attempting to perform a type cast.
Error: 0xC0209029 at Import from ODS to DWH, Derived Column [2]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Derived Column" failed because error code 0xC0049064 occurred, and the error row disposition on "Derived Column.Outputs[Derived Column Output].Columns[timestamp]" 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 Import from ODS to DWH, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Derived Column" (2) failed with error code 0xC0209029 while processing input "Derived Column Input" (3). 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: 0xC02020C4 at Import from ODS to DWH, OLE DB Source [62]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0047038 at Import from ODS to DWH, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source 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.
Explicitly changing types in source (so they match destination) and connecting directly to destination.
Error: 0xC020901C at Direct, OLE DB Source [32]: There was an error with OLE DB Source.Outputs[OLE DB Source Output].Columns[time] on OLE DB Source.Outputs[OLE DB Source Output]. The column status returned was: "The value could not be converted because of a potential loss of data.".
Error: 0xC0209029 at Direct, OLE DB Source [32]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE DB Source.Outputs[OLE DB Source Output].Columns[time]" failed because error code 0xC0209072 occurred, and the error row disposition on "OLE DB Source.Outputs[OLE DB Source Output].Columns[time]" 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 Direct, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source returned error code 0xC0209029. 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.
Data Conversion. Same result: failure.
Error: 0xC02020C5 at Conversion, Data Conversion [2]: Data conversion failed while converting column "time" (74) to column "Copy of time" (11). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
Error: 0xC0209029 at Conversion, Data Conversion [2]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of time]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of time]" 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 Conversion, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Data Conversion" (2) failed with error code 0xC0209029 while processing input "Data Conversion Input" (3). 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: 0xC02020C4 at Conversion, OLE DB Source [62]: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
Error: 0xC0047038 at Conversion, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source 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.
So now I just ran out of tools and ideas how to do this: most instructions just say something like "map this to that and it will work". I'm struggling with this so hard and for so long I even created a StackExchange account for that. Any help appreciated. Cheers.
This message
The value could not be converted because of a potential loss of data.
tells you pretty much everything you need to know. Your problem isn't with the types you're using, it's with the data in your source.
The most likely cause is at least one row of data in your source ODS has values which are in a format that cannot be recast into (for example) a DB_TIMESTAMP.
My recommended approach would be to cast all your source columns explicitly in your SQL source statement.
So instead of
select time, value from source
do
select (cast time as datetime) as time, (cast value as int) as value from source
In fact, I would run this query against your source table to make sure all the values can be correctly cast into the final fields. (My guess is not or you wouldn't get casting errors.)
Another thing you could do is change your task components from "Fail" on error to "Redirect error rows" and push the error rows into a file destination so you can see which rows are getting kicked out by the transformation component.
New Answer to an old question - but I just pulled all of my hair out trying to solve this error. Multiple error paths, data conversion, derived columns, etc. were not working. Two things solved this error:
I noticed that columns with Null Values were causing errors when dealing with Curreny (DT_CY) .
I finally solved this error by checking a little box "Retain null values from source as null values in the data flow" that was within the Flat File Source node. (why is this not selected by deafult!?)
Second, I was having a hard time converting dates to strings - an easy solution would be to do an update statement within a Execute SQL Task within the control flow.
For example: your database column is varchar or nvarchar. Your Source has data coming in a mm/dd/yyyy. No matter how many times you try wrestling with the above error, converting this into a string fails.
I solved this by loading the data (you can use a temp table if you'd like) and then converting this column using a SQL Query. I personally used:
update MY_TABLE_NAME
set [MY_DATE_COLUMN] = convert(varchar(8),CONVERT (datetime,[MY_DATE_COLUMN] ), 112)
where (FILTER_STATEMENT_TO_UPDATE_ONLY_WHAT_YOU_JUST_LOADED)
Hopefully this can assist others who stumble upon this post.
(DT_R8)(REPLACE(Knowledgeable,"\"","") == "" ? NULL(DT_R8) : (DT_R8)REPLACE(Knowledgeable,"\"",""))
Try the above code.
What's happening is that you are trying to convert a value that has double qoutes. That is why it's giving you an error. Replacing the double qoute with an empty string will solve the problem.

Resources