SSIS string truncation error - sql-server-2005

I have a SQL Server 2005 SP2 database which has a table with a poc_resp_city attribute which is nvarchar(35).
It was changed to nvarchar(80) 2 months ago without aligning the very same attribute in the data warehouse. (which still has nvarchar(35) )
The SSIS data loading package (after two months of proper working) now gives back package failure every time I run it with the following error:
There was an error with output column "poc_resp_city" (2250) on output
"OLE DB Source Output" (11). The column status returned was: "Text was
truncated or one or more characters had no match in the target code
page.". There was an error with output column "poc_resp_city"
(2250) on output "OLE DB Source Output" (11). The column status
returned was: "Text was truncated or one or more characters had no
match in the target code page.".
SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on
component "Source Table" (1) 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.
Neither the package nor the databases were modified regarding this issue. I know that I could ignore this error or I could make the arrangements to make sure it's working but I want to provide a proper and acceptable answer why this error appears 2 months after the modification? Because maybe I miss an important step in this situation.
Important note: I don't have even a single record which has more than 35 characters so truncation never occurs. (this warning belongs to some kind of an SSIS validation step)
Now I think that maybe after a period of time, SSIS package recompiles itself and now it sees this misalignment in its metadata (35 =/= 80) and because TruncationRowDisposition attribute is set to RD_FailComponent, it fails the component.
And I would exclude the code page option because every database column is nvarchar, not varchar, so this shouldn't be the case.
Thanks!

You need to refresh size of column:
With right button push on OLE DB Source -> Show Advanced Editor
Choose Input and Output Properties tab -> Ole DB Source Output -> Output Columns
In the right panel Length row insert your new size.
Push OK
Or you can copy your query from OLE DB Source, delete OLE DB Source, insert new OLE DB Source and paste query. This gonna automaticily refresh your columns.
Just remember what there are probably more element in Dataflow where you need to edit length of your column, like Data Converion...

Related

Ssis error invalid column reference in package

I have an invalid column reference error in my sis package after editing my stored procedure with a case statement which added a column total sales from amount paid. Please can someone help with this? I cannot remap the columns in the package unless I resolve the error. Thanks
I faced a similar problem in my SSIS package. After adding a few new columns to my source table the "OLE DB Source" element would not map these new columns correctly either not displaying them at all on the mapping list or showing the "invalid column" error.
It turned out that the connection I was using had the RetainSameConnection parameter set to True (the package uses temp tables that are not to be dropped) - changing this to False enabled me to add the new columns to the mapping.
It might also be a good idea to check the DelayValidation and ValidateExternalMetadata parameters on elements connected to the data flow. These should probably be set to True in this case.
Perhaps someone runs into the same problem.
It seems that SSIS external metadata refresh is happened. If you change an underlying query that your SQL Server Integration Services (SSIS) package is relying on, you get the same message.
You can fix it by using Restore Invalid Column References Editor.Use this dialog box to restore the mappings of invalid column references. Set the Available Columns item to "" for all the entries and click OK. You should then be able to continue and remap the columns between source and destination.
If you couldn't see Restore Invalid Column References Editor then follow below steps.
Right-clicking the box with the warning sign
Selecting "Show Advanced Editor"
Activating "Column Mappings"
Clicking "Refresh"
Otherwise delete destination connection and rebuilding it from scratch.

Can't convert String to Numeric/Decimal in SSIS

I have five or six OLE DB Sources with a String[DT_STR], with a length of 500 and 1252 (Latin) as Code Page.
The format of the column is like 0,08 or 0,10 etc etc. As you can see, it is separated with a comma.
All of them are equal except one of them. In this one source, I have a POINT as separation. On this it is working when I set the Data Type in the advanced editor of the OLE DB Source. On another (with comma separated) it is also working, if I set the Data Type in the advanced editor of the OLE DB Source. BUT the weird thing is, that it isn't working with the other sources although they are the same (sperated with comma).
I tested Numeric(18,2) and decimal(2).
Another try to solve the problem with the conversion task and/or the derived column task, failed.
I'm using SQL Server 2008 R2
Slowly, I think SSIS is fooling me :)
Has anyone an idea?
/// EDIT
Here a two screens:
Is working:
click
Isn't working:
click
I would not set the Data Type in the Advanced Editor of the OLE DB Source. I would convert the data in the SQL Code of the OLE DB Source, or in a Script Transformation e.g. using Decimal.TryParse , which would update a new column.
SSIS is unbeleivably fussy over datatypes and trying to mess with its internals is not productive.
Check that there are any spaces in between the commas, so that the SSIS is throwing an error trying to convert the blank space to a number. A blank space does not equal nothing in between spaces.
Redirect error rows and output the data to a file. Then you can examine the data that is being rejected by the SSIS and determine why it's causing error.
Reason for the error
1) Null’s are not properly handled either in the destination database or during SSIS package creation. It is quite possible that the source contains a null database but the destination is not accepting the NULL data leading to build generate above error.
2) Data types between source and destination does not match. For example, source column has varchar data and destination column have an int data type. This can easily generate above error. There are certain kind of datatypes which will automatically convert to another data type and will not generate the error but there are for incompatible datatypes which will generate The value could not be converted because of a potential loss of data. error.
The Issue arises when there is unhandled space or null. I have worked around using the Conditional (Ternary) Operator which checks the length:
LEN(TRIM([Column Name])) >= 1 ? (DT_NUMERIC,38,8)[Column Name] : 0

VS 2005 SSIS Error value origin

I have an ssis package created in vs 2005 that has started to give me the following error:
[Lawson Staging Table [4046]] Error: There was an error with input column "JOB_CODE" (4200) on input "OLE DB Destination Input" (4059). The column status returned was: "The value violated
the integrity constraints for the column.".
My first question is: what are the 4046, 4200 & 4059 values following my table, column and destination?
My second question is about the integrity constraint message. The destination table is a heap (no keys or indexes) with no constraints. The destination column is defined as a varchar(10). The input column is from oracle, is defined as char(9) and is called job_code. So - where is there an integrity constraint defined?
The final question is about the select statement; looks like the following:
Select ...
,lpad(trim(e.job_code),10,'0') as job_code ...
If I take the lpad and trim functions out, it works but I need these functions in place because my spec calls for a fixed length column padded with leading zeros. This column returns data as expected in TOAD but fails in the ssis package. Does anyone see an issue with how the functions are being used?
Since this package worked in the past but suddenly started to throw this error, I'm assuming that new invalid data has come into play. however, recently added rows don't seem to be any different then historical records.
Those numbers are more likely to be the ids assigned to the each task/table/column etc.
You could probably go to the advanced editor of the data flow task and look at the input and output properties. You can see that for each input or for each column there is an ID assigned.
Next: The error that you are getting occurs usually when "Allow Nulls" option is unchecked.
Try this:
Look at the name of the column for this error/warning.
Go to SSMS and find the table
Allow Nulls for that Column
Save the table
Rerun the SSIS

"Invalid date format" when importing flat file with Import Wizard

Good afternoon,
I have a dilemma that I cannot figure out. I am trying to import a flat file in a SQL db table but am having issues. My column in SQL is a date time column for date of birth DOB. The extraction flat file provided to me has this column as date...thus when I importin to SQL I am getting:
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 10.0" Hresult: 0x80004005 Description: "Invalid date format".
(SQL Server Import and Export Wizard)
Error 0xc020901c: Data Flow Task 1: There was an error with input column "DOB" (212) on input "Destination Input" (147). The column status returned was: "Conversion failed because the data value overflowed the specified type.".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "Destination Input" (147)" failed because error code 0xC020907A occurred, and the error row disposition on "input "Destination Input" (147)" 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)
I am trying to figure out how to add a random time like 00:00:00.000 to every DOB in the flat file. example, they send me 1983-11-30 but I want to use 1983-11-30 00:00:00.000
Is there a way to do this or does anyone have an idea of what I can do? Thanks in advance
My situation was a little different but I feel posting about it could help others out there. Unlike OP, I was importing data from an Access 2000 mde file into sql server management studio, but similar to OP I ran into the "Invalid data format" error. I knew the conflict was caused by the fact that the columns of type DateTime in the access file conflicted with the DataTime format in sql.
Solution: After I went through the import data process, which is done by right clicking the server name in sql server management studio -> Tasks -> Import Data and then choosing the source (access), destination (sql server), and table to be imported, I noticed that 0 rows were transferred because of the type issue. However, a table was created for me in SQL Server Management Studio that represented the table I was trying to import from the access table. It had the right columns and their associated data types.
So what I did was I right clicked the table in order to go into design view and changed all the data types of the DataTime columns to just Date,
Then I redid the import data process, and the rows were successfully transferred.
MSSQL will have no problem converting a yyyy-MM-dd string like yours to a date. You'll end up with 00:00:00.000 automatically. The error message you posted "Conversion failed because the data value overflowed the specified type" indicates that one of the dates is outside the valid range. You most likely got an invalid date of birth (look for a 0000-00-00 record or similar). If the flat file is delimited in a way Excel can easily parse, pull it into Excel and sort that column. Look at both the smallest and largest values and you'll likely find the offending record(s).
I changed the type of row from datetime to date (in the mapping) while importing the data via Wizard and it worked for me.
This is old, but I was having a similar issue in my SSIS data flow task and hopefully this might help someone: for me the solution was to check the "Retain null values from the source as null values in the data flow" option in the Flat File Source Editor window (in the Connection Manager page)
I found that when copying a database from the local EXPRESS to my production server, the table definitions were smalldatetime instead of datetime. In the wizard where you select the tables, you can select Edit Mapping. In there you can change your data type.

How to Convert NTEXT values to BOOLEAN using SSIS

I'm using SSIS to import SalesForce data into SQL Server. In SF, I have ntext fileds that contain values like "Live/ Not Live" which can easily be interpreted with a bit filed in SQL Server.
Is there a way to convert these ntext fields to Boolean values using SSIS. I have tried using Derived Column transformation and get the following errors:
[Insert Destination [807]] Error: SSIS Error Code DTS_E_OLEDBERROR.
An OLE DB error has occurred. Error code: 0x80040E21. An OLE DB record
is available. Source: "Microsoft SQL Server Native Client 10.0"
Hresult: 0x80040E21 Description: "Multiple-step OLE DB operation
generated errors. Check each OLE DB status value, if available. No
work was done.".
[Insert Destination [807]] Error: SSIS Error Code
DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "OLE DB Destination
Input" (820)" failed because error code 0xC020907B occurred, and the
error row disposition on "input "OLE DB Destination Input" (820)"
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 "Insert Destination" (807) failed
with error code 0xC0209029 while processing input "OLE DB Destination
Input" (820).
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.
Any help would be greatly appreciated.
NTEXT is your unicode text stream. You can't do much with a stream so we'll need to make it into something more manageable like DT_STR or DT_WSTR. Whether you have internationalization in your text data is something only you will know. Either way, connect a Data Conversion Transformation up to your SF source and make that data into a non-stream type (give it a max width). The goal of this operation is to take the stream data and turn it into straight text values (Live, Not Live). I'm assuming this column will be called IsLiveString
Now that you're dealing with a string type, add your Derived Column Transformation to the Conversion output and here is where you will need an expression to determine whether the supplied values from the Data Conversion task evaluate to True/False. Even if SQL Server understood that Live translates to a 1 (true), there is no way in heck I'd want to rely on that magic working forever. Instead, I'd look to create a new column, IsLiveBoolean and it'd have an expression like ([IsLiveString]=="Live") ? True : False That expression is approximate, I'm not sitting an instance of SSDT/BIDS. It could also be simplified by eliminating the ternary expression in lieu of the equality check. If you need to deal with NULL values in the IsLiveString column, then the ternary operator syntax makes that evaluation easier.
Edit
A picture's worth a thousand words so consider this 3k and some change. This represents the actions in your data flow. I used a simple query to POC your example. I generate a column of data type ntext with values of "Live" and "Not Live" and a NULL. From the source, I use the Data Conversion task as described above. I went with DT_WSTR to make this answer apply to the broadest possible audience and left the length at the default of 50. To optimize your memory usage, you'd want to decrease the length to match the longest possible value from the source system.
I configured my Derived Column transformation thusly. Options are there for dealing with NULLs or if you know your data is NULL free then the first will work.
Results. You can observe that this correctly makes the strings into their corresponding boolean counterparts. Those would then be piped into your destination component.