Derived column expression validation error - ssis

I have write the below code in my derived column expression in ssis package.
Input values as i am receiving from source:-
Q:\SOURCE\RV_T\PCL_RVT\RVT_export_all_2011-02-14_08.38.00_Emerald.xlsx
i want :- RVT_export_all_2011-02-14_08.38.00_Emerald.xlsx
Substring(#[User::V_FilePath],LEN(#[User::V_FilePath]) - Charindex("\",Reverse(#[User::V_FilePath]))+2,LEN(#[User::V_FilePath]))
its running fine in SSMS but giving below error in SSIS
Error at DFT - Load Data [Derived Column [8]]: Attempt to parse the
expression "Substring(#[User::V_FilePath],LEN(#[User::V_FilePath]) -
Charindex("\",Reverse(#[User::V_FilePath]))+2,LEN(#[User::V_FilePath]))"
failed. The token """ at line number "1", character number "68" was
not recognized. The expression cannot be parsed because it contains
invalid elements at the location specified.
Error at DFT - Load Data [Derived Column [8]]: Cannot parse the
expression "Substring(#[User::V_FilePath],LEN(#[User::V_FilePath]) -
Charindex("\",Reverse(#[User::V_FilePath]))+2,LEN(#[User::V_FilePath]))".
The expression was not valid, or there is an out-of-memory error.
Error at DFT - Load Data [Derived Column [8]]: The expression
"Substring(#[User::V_FilePath],LEN(#[User::V_FilePath]) -
Charindex("\",Reverse(#[User::V_FilePath]))+2,LEN(#[User::V_FilePath]))"
on "Derived Column.Outputs[Derived Column
Output].Columns[filenaemfrompat]" is not valid.
Error at DFT - Load Data [Derived Column [8]]: Failed to set property
"Expression" on "Derived Column.Outputs[Derived Column
Output].Columns[filenaemfrompat]".
Please suggest.
Thanks in advance...

Finally after lot of testing i am able to get what i want.
Here is the code i used
RIGHT(#[User::V_FilePath],FINDSTRING(REVERSE(#[User::V_FilePath]),"\\",1) - 1)

Related

Error when using data conversion in only one column SSIS

I have an XML source that contains a column for [Cellphone] which is basically a 10 digits phone number, im using data conversion to convert this column to varchar(50) to match what I have on the table but i get this error whenever I run the package.
[Data Conversion 1 [136]] Error: Data conversion failed while converting column "CO-CellPhone" (763) to column "Copy of CO-CellPhone" (234). The conversion returned status value 6 and status text "Conversion failed because the data value overflowed the specified type.".
[Data Conversion 1 [136]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "Data Conversion 1.Outputs[Data Conversion Output].Columns[Copy of CO-CellPhone]" failed because error code 0xC0209082 occurred, and the error row disposition on "Data Conversion 1.Outputs[Data Conversion Output].Columns[Copy of CO-CellPhone]" 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.
I tried to change it to integer but it didn't work, I checked the XML source and this is the value
<CO-CellPhone>4855895687</CO-CellPhone>
This is dummy data by the way :)
Thanks in advance

Problem to import datetimeoffset from csv file to a table via SSIS

I've a csv as a source file that I'm trying to load the data from this file to a stage SQL server table. There are three date columns. The below is an example of values of these columns:
2007-10-02T08:46:13+02:00
On SQL server side, I've defined datetimeoffset(7) as datatype and in SSIS connection manager selected database timestamp with timezone [DT_DBTIMESTAMPOFFSET] as datatype. But I'm getting the following error for importing datetime columns:
Data conversion failed. The data conversion for column "column1"
returned status value 2 and status text "The value could not be
converted because of a potential loss of data.".
Error: 0xC0209029 at
Data Flow Task, Flat File Source [2]: SSIS Error Code
DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Flat File
Source.Outputs[Flat File Source Output].Columns[column1]" failed
because error code 0xC0209084 occurred, and the error row disposition
on "Flat File Source.Outputs[Flat File Source
Output].Columns[column1]" 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: 0xC0202092 at Data Flow Task,
Flat File Source
[2]: An error occurred while processing file "\path to file.csv" on
data row 2. Error: 0xC0047038 at Data Flow Task, SSIS.Pipeline: SSIS
Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Flat
File Source returned error code 0xC0202092. 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.
Do you how to fix it? Or why I'm getting this error?
try first to load it as string (length 25 or so) and then try to substring it using Converting Columns in ssis and then you can try and cast it to datatype of datetime in another Converting Columns before loading to your table.
In the Flat File connection manager, leave the column data type to string (DT_WSTR or DT_STR) and in the Data Flow Task add a Derived Column Transformation with the following expression:
(DT_DBTIMESTAMPOFFSET, 7)REPLACE([DateColumn],"T"," ")
Example:
I was having the same problem. When i tried to export data that already have date time stamp it produces date format like below. If you change your date format i hope it will work.
My date format -> 2022-09-14 11:00:00.0000000 +00:00
Your date format -> 2007-10-02T08:46:13+02:00

SSIS Error converting date from DT_STR to database timestamp [DT_DBTIMESTAMP]

I have a TAB Delimited file which I am downloading to a database table. The table has columns with datatypes nvarchar(50) but a date column with datatype of datetime. The TAB Delimited file has all datatypes DT_STR. I converted all fields with datatype DT_STR to DT_WSTR but I need to convert the date from ST_STR to database timestamp [DT_DBTIMESTAMP]. However, I keep getting the following error:
[Data Conversion [2]] Error: Data conversion failed while converting column "Reason Code Date" (150) to column "Copy of Reason Code Date" (82).
The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
[Data Conversion [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of Reason Code Date]" failed because error code 0xC020907F occurred, and the
error row disposition on "Data Conversion.Outputs[Data Conversion Output].Columns[Copy of Reason Code Date]" 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 "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.
I need the date column in the table to look like this after the conversion:
ReasonDate
2018-04-19 00:00:00.000
2019-05-10 00:00:00.000
2018-12-09 00:00:00.000
2018-03-09 00:00:00.000
2018-09-21 00:00:00.000
2018-02-06 00:00:00.000
How can I achieve this without getting a conversion error?
It was determined that the data in the file was chopped off at the end of the list, which made the date column blank and why the error was encountered. The problem was resolved by recreating the list with all the date fields having dates (MM/DD/YYYY format). The dates was converted in SSIS from ST_STR to database timestamp [DT_DBTIMESTAMP], and when the job was run again the date conversion was done correctly (to format '2018-04-19 00:00:00.000'), and the job completed successfully.

ssis sql 2000 image to 2008 varbinary Failed to retrieve long data for column

I have a task that to migrate the image type column from sql 2000 to varbinary type in sql 2008.
The source column having 3812353 max datalength size for the column.
The package always failed with following error message.
[OLE DB Source [13177]] Error: Failed to retrieve long data for column "attch_file_content_t".
[OLE DB Source [13177]] Error: There was an error with output column "attch_file_content_t" (13209) on output "OLE DB Source Output" (13187). The column status returned was: "DBSTATUS_UNAVAILABLE".
[OLE DB Source [13177]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "attch_file_content_t" (13209)" failed because error code 0xC0209071 occurred, and the error row disposition on "output column "attch_file_content_t" (13209)" 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.
It basically was the connection error.
i manage to solve the connection issue on one table but now found another issue on another table.
The initial intention is migrate the source data to staging.
The source are sql 2000, they have some attachment as an image type
Then we have the Failed to retrieve long data for column issue when we just do the select * from tableA
Then I try to do the select cast(ImageTypeColumn) as varbinary(8000) from tableA
now it work for those data which is not exist 8000 byte
But unfortunately in the another table, there exist some rows data length is huge.
Thus it failed again when we do the select cast(ImageTypeColumn) as varbinary(8000) from tableA
In Microsoft SQL Server 2000 and earlier versions, the varbinary data type had a maximum limit of 8,000 bytes. To store up to 2 GB of binary data the image data type needs to be used instead.
Finally i found a solution on that.
Using ADO.net Source instead of using the OLEDB.net Source

SSIS IsNumeric expression Error

Hi am using following exression in ssis package
!ISNULL((DT_I4)Route) ? (DT_WSTR,50)("SB" + SUBSTRING(RIGHT(Route,2),1,1)) : (DT_WSTR,50)Route
when the Route value is Numeric it is sucess, when it is Non-numeric failing with
following description. Any help,how to resolve this issue
[Derived Column [111]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "component "Derived Column" (111)" failed because error code 0xC0049067 occurred, and the error row disposition on "output column "column_New" (679)" 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 "Derived Column" (111) failed with error code 0xC0209029 while processing input "Derived Column Input" (112). 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.
The following part of your conditional statement "(DT_I4)Route" is attempting to cast Route as a 4 byte Integer. You do not need to cast Route to a DT_I4 to test for Null.
EDIT --
I had missed that you were trying to test for non-numeric.
So here is how I would do this:
In your derived column transform have one column that has the expression (DT_I4)Route and one column where the expression is (DT_WSTR,50)Route
On the Column that is derived from (DT_I4)Route set the Error Output to Redirect Row
On the Error Output flow have a second Derived Column that uses the expression
(DT_WSTR,50)("SB" + SUBSTRING(RIGHT(Route,2),1,1)) that is named the same as your column from the first derived column transform, and use a Union ALL to merge them back together.
From my testing, the expression you used returns null as soon as you encounter an error (and casting an non-numeric to a DT_I4 is an error) but only if you have your error output set to something other than fail component. Ignore Failure won't work since you will then just get null for the whole expression where the value is non-numeric.