Question

I use a Data Flow Task in SSIS to get data from one server (SQL Server 2005) to another (SQL Server 2008 R2). In the OLE DB Source connection I use an SQL command to get the data. In this command, I am already casting content as a certain data type:

SELECT
CAST(column1 AS VARCHAR(10)) AS NameColumn1
,CAST(column2 AS INT) AS NameColumn2
,CAST(REPLACE(REPLACE(REPLACE(REPLACE(column3, CHAR(10), ''), CHAR(13), ''), CHAR(9), ''), ';', '-') AS VARCHAR(100)) AS NameColumn3
,CAST(REPLACE(REPLACE(REPLACE(REPLACE(column4, CHAR(10), ''), CHAR(13), ''), CHAR(9), ''), ';', '-') AS VARCHAR(255)) AS NameColumn4
...
FROM (etc.)

(Note that the casts are casting to the original data type of the column values in the source database. So the data type of column1 is originally VARCHAR(10), that of column4 is originally VARCHAR(255), etcetera.)

These casts are used because further on in the package I got the following warning for column3 and column4:

Validation warning. [...] Truncation may occur due to inserting data from data flow column "column4" with a length of 8000 to database column "column4" with a length of 255.

It seems as if the casts do not work though, because the truncation warnings for column3 and column4 keep coming. (I have already set the truncation warning in the OLE DB Source to Ignore failure, but that does not seem make a difference.)

I can't find anything on this online and will for the time being 'solve' this by importing the columns as VARCHAR(8000). But I'd love to know what the cause of this behaviour in SSIS is. Anyone got a clue?

Was it helpful?

Solution

Go into the Advabnced Properties of the source component and verify the size of the 3rd and 4th columns (within Input and Output Properties). If they have already been calculated as varchar(8000) then you will have to change them manually.

Alternatively, delete the component and add a new one with your Select / Cast in place from the beginning - this should correctly assign the right field length.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top