PRECEDENCE CONSTRAINT: DATA TYPE CONVERSION ERROR
-
Friday, August 10, 2012 8:06 PM
I'm getting error for the following code:
LEN (@[User::strFileName]) == 17&& (DT_I8)SUBSTRING(@[User::strFileName],6,2) < 13 && (DT_I8)SUBSTRING(@[User::strFileName],8,2) < 32 && DATEDIFF("dd",(DT_Date)(SUBSTRING(@[User::strFileName],6,2) + "-"+SUBSTRING(@[User::strFileName],8,2) + "-" + SUBSTRING(@[User::strFileName],10,4)),GETDATE()) > @[User::intFileMaxAge]
Note: strFileName is String variable
intFileMaxAge is Int32 variable
I'm gettign following error:
Error at constraint : Error code 0x80020005 occured attempting to convert from data type DT_WSTR to data type ST_I8
Error at constraint :Casting expression "SUBSTRING(@[User::strFileName],6,2) from DT_WSTR to data type DT_I8 failed.
ZK
- Edited by SQL_Admirer Friday, August 10, 2012 8:23 PM CHANGED SUBJECT
All Replies
-
Friday, August 10, 2012 8:41 PM
HERE IS THE SNAP SHOT.
ZK
-
Friday, August 10, 2012 8:48 PMModerator
How does the file name look like?
It is most likely the issue is in the data. E.g. (DT_I8)SUBSTRING(@[User::strFileName],6,2) cannot cast from a non-numeric value
Arthur My Blog

-
Friday, August 10, 2012 8:51 PM
to build an expression your variables should have a valid default values as well. The expression builder uses variable current values to evaluate the expression.
I used "Filen010120012thisworks" as a file name.
Please mark the post as answered if it answers your question
- Edited by DotNetMonster Friday, August 10, 2012 8:54 PM update
-
Friday, August 10, 2012 8:52 PM
Its like "FileName_MMDDYY.txt"
or filename with time stamp
ZK
-
Friday, August 10, 2012 8:55 PMModerator
This helps to find out that
SUBSTRING(@[User::strFileName],6,2) cannot be converted to INT because it is text
Arthur My Blog

- Proposed As Answer by Eileen ZhaoMicrosoft Contingent Staff, Moderator Thursday, August 16, 2012 8:59 AM
- Marked As Answer by Eileen ZhaoMicrosoft Contingent Staff, Moderator Tuesday, August 28, 2012 2:34 AM
-
Friday, August 10, 2012 8:58 PM
your expression requires the date to start from 6th character, if it does not, your expression will blow a run time error. you should reconsider doing this in a "Script Task" and set a bool variable to true or false based on the validation.Its like "FileName_MMDDYY.txt"
or filename with time stamp
ZK
Please mark the post as answered if it answers your question

