I am getting the below message while executing a package.
Text was truncated or one or more characters had no match in the target code page.
I am taking data from an SQL table which has a field names task_teammember
with the data type VARCHAR(MAX)
. The package exeuction fails at the source. I type casted the column task_teammber
into VARCHAR(8000)
which executes the package without any error message. However, the destination receives only 8000 characters whereas there are more than 8000 characters in the source table.
How do I transfer all the data from source to destination tables using SSIS when the columns are defined as VARCHAR(MAX)
?
You need to use the SSIS datatype
text stream [DT_TEXT]
to fetch data from SQL Server table columns of data typevarchar(MAX)
Here is a simple example that illustrates how SSIS automatically infers the datatypes from the source. The example uses SQL Server 2008 R2 database and SSIS 2008 R2
Create the following tables in SQL Server database to store source text and use the destination to insert the text using SSIS package.
Insert text of large length into source table . You can see the data in the source table containing more than 10,000 characters and the destination table is empty before executing the package.
Create an SSIS package with a connection manager to the database. Place a data flow task on the Control Flow task. Within the data flow task, place an OLE DB Source and OLE DB Destination to transfer data from
dbo.SourceTable
todbo.DestinationTable
. Here the screenshots shows the execution status of the package.If you run the query again, you will see that the destination table is populated with the text from source table using SSIS package without any truncation errors.
Go back to the package's data flow task tab and right-click on the
OLE DB Source
and then clickShow Advanced Editor...
On the
Advanced Editor for OLE DB Source
, click Input and Output Properties tab. ExpandExternal Columns
and selectSourceText
. You will notice that the SSIS set the column data type to textstream [DT_TEXT]
based on the data typeVARCHAR(MAX)
defined on the source table.Here are the mappings for SQL Server data types VARCHAR(MAX) and NVARCHAR(MAX) in SSIS.
VARCHAR(MAX) ---> text stream [DT_TEXT]
NVARCHAR(MAX) ---> Unicode text stream [DT_NTEXT]
Read more about it on MSDN Integration Services Data Types
Hope that helps.