Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSIS - Converting DT_TEXT(Length 11,000 Characters) to DT_STR and trim to 1,000 characters

I want to read data from text file (.csv), truncate one of the column to 1000 characters and push into SQL table using SSIS Package.

The input (DT_TEXT) is of length 11,000 characters but my Challenge is ...

  • SSIS can convert to (DT_STR) only if Max length is 8,000 characters.
  • String operations cannot be performed on Stream (DT_TEXT data type)
like image 842
Vijred Avatar asked Feb 11 '15 13:02

Vijred


People also ask

What is Dt_str in SSIS?

DT_STR: It is a null-terminated ANSI/MBCS character string with a maximum length of 8000 characters. DT_UI1: It is a one-byte, unsigned integer.

What is Dt_ntext in SSIS?

Since the column is a VARCHAR(MAX) data type in SQL Server, SSIS treats this as a DT_TEXT datatype. The DT_TEXT and DT_NTEXT are text data types and there are several limitations related to handling these datatypes in SSIS. For example, none of the string functions would work with these data types.


2 Answers

Got a workaround/solution now; I truncate the text in Flat File Source and selected the option to Ignore the Error;

Please share if you find a better solution!

FYI: Truncating8000PlusCharsInSSIS

like image 65
Vijred Avatar answered Nov 15 '22 10:11

Vijred


To help anyone else that finds this, I applied a similar concept more generally in a data flow when consuming a text stream [DT_TEXT] in a Derived Column Transformation task to transform it to [DT_WSTR] type to my defined length. This more easily calls out the conversion taking place.

Expression: (DT_WSTR,1000)(DT_STR,1000,1252)myLargeTextColumn
Data Type: Unicode string [DT_WSTR]
Length: 1000

*I used 1252 codepage since my DT_TEXT is UTF-8 encoded.

For this Derived Column, I also set the TruncationRowDisposition to RD_IgnmoreFailure in the Advanced Editor (or can be done in the Configure Error Output, setting Truncation to "Ignore failure")

(I'd post images but apparently I need to boost my rep)

like image 34
NickF Avatar answered Nov 15 '22 10:11

NickF