Showing posts with label lookup. Show all posts
Showing posts with label lookup. Show all posts

Tuesday, March 20, 2012

Problems with Lookup task and dates

I’m trying to make a Lookup transformation with a relation on two string columns and a between dates condition set by parameter:

select * from
(select * from [dbo].[RgnErhverv_Ansvar]) as refTable
where [refTable].[Opretdato] = ? and ? between StartDate and EndDate

where the second parameter is my Date column (FakturaDato_konv) .

My problem is that I keep getting the error:

"Error 1 Validation error. Data Flow Task: Lookup [16505]: input column "FakturaDato_konv" (17826) has a datatype which cannot be joined on"

The StartDate and EndDate is datetime data type and have tried all of the DATE data types for the "FakturaDato_konv" without any luck - DT_DBTIMESTAMP should be the one.

FakturaDato_konv looks like this 24-06-2005 00:00:00
StartDate looks like this 31-08-2001 00:00:00

Any suggestions?

-Jeppe

I tried your lookup string in here and received no error so I don't know specifically what your problem is. You mention above 2 strings and a date but your SQL only has 2 parameters so maybe that is the problem. You should look at the parameters dialog to see if the columns are being joined as you expect. That all being said lookup is a one to one lookup so in general what you are trying to do won't work even if you get the SQL statement problem ironed out.

Thanks,|||

The first parameter is a string value and the second is the date value. The string value is working fine but the date value is causing me problems. I have mapped the parameters to the correct columns in the parameters dialog and manually added the date column (second parameter) to the input columns the advanced editor.

The two date values in my post represent the second parameter and one of the date values in the lookup table – they are same format but I keep getting the has a datatype which cannot be joined on?

I have tried joining on only one date parameter.. same error.

Thanks
-Jeppe

|||

Are there any other errors posted? Have you tried fully qualifying startdate and enddate (e.g. [reftable].[startdate])? Error 1 does not look like an error we post did you cut and paste the entire error (i.e. our errors look like 0xCxxxxxxx)? As I asked previously did you look at the parameter dialog to see the mapping? Did you verify that the metadata for the dataflow column is the type you expect it is?

Thanks,

|||

The warning i like the one I posted and the error messagebox is:

TITLE: Package Validation Error

Package Validation Error


ADDITIONAL INFORMATION:

Error at Data Flow Task [Lookup [18314]]: input column "FakturaDato_konv" (18427) has a datatype which cannot be joined on.

Error at Data Flow Task [DTS.Pipeline]: "component "Lookup" (18314)" failed validation and returned validation status "VS_ISBROKEN".

Error at Data Flow Task [DTS.Pipeline]: One or more component failed validation.

Error at Data Flow Task: There were errors during task validation.

(Microsoft.DataTransformationServices.VsIntegration)


BUTTONS:

OK
The log says:

[DTS.Pipeline] Error: The ProcessInput method on component "Lookup" (18314) failed with error code 0xC0209029. 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.

I have checked the column mappings and the format in metadata. I also tried a simpel lookup only on one of the date columns - samme error.

Maybe my package is corrupted?

Thanks
-Jeppe

|||I found the error Idea

The date column (FakturaDato) had to be mapped to one of the lookup date columns (StartDate or EndDate) - it's not enough that the string column (Ansvar) was mapped and the date columns manually added as input columns in the advanced editor.

Hope this makes sense

Thanks
-Jeppe

Problems with LOOKUP component (repost)

Hello,
Can anyone address these:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=142849&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=142837&SiteID=1

-JamieAnyone?

Where's Matt David when you need him :)

-Jamie|||Jamie,
It does make sense that you can't override the sql statement for a lookup component since you would typically connect to a relatively static table to import in a related column. My example would be to pull in a State's full name when the source file only has a State code (NY --> New York).
What are the circumstances for which you need to override the sql statement?

You could try using a stored procedure as the SQL command and passing in your variables.
exec SPName [User::Variable], [User::Variable]
From what I've tested this only works when the stored procedure is expecting nvarchars and the variables are strings. Any other types cause conversion errors.
Larry|||Do you know what Larry...I honestly can't remember. Embarrassing huh?

I am making an educated guess that it was something to do with limiting the the amount of data that you cache. In some situations you will know that the data in your pipeline could only be in a subset of the target, so what's the point in pulling back the whole of the target?

For example - you are using a LOOKUP to determine whether the incoming rows are new or changed rows. You know that rows in the source can only be updated within 2 weeks of being created (this is a real world scenario that I have come across) so you only want to pull back stuff that was created in the past 2 weeks. Admittedly in this scenario you could use GETDATE() but it demonstrates how the data required in the cache may only be a subset of the total data and that subset will change over time.

Another scenario would be where the data-flow is in a for each loop so it can pull data from numerous sources. The target has a field indicating which source each row has come from so in your LOOKUP you only need to cache data from the source that is currently being processed.

Make sense?

-Jamie|||I can't think of the exact scenario right now, but I know I have wanted to do the same thing. I want to restrict the reference data to a subset, but the filter clause can change, and you would want to parameterise it, usefull feature in my book.|||Jamie,
I do remember other posts regarding that type of scenario. I just looked at the Lookup transformation again. Couldn't that be accomplished by using the Modify SQL Statement under the Advanced tab and mapping your lookup parameters correctly?
For example if your source data looks like as follows
Col A Col B Col C
1 A X
2 A Y
3 B Z
And your lookup for Col B looks like as follows
Col B Description
A A's Description
B B's Description
...
Z Z's Description
You could map the lookup parameter to the source's Col B. I'm not sure about the performance impact on the lookup column. It might do a group by on the source to get the unique parameters, or it might do a value by value lookup if it's not already in the cache.
The only downside is that the lookup subset parameters need to have corresponding values in the source.
The other mechanism for large lookups is to use a Merge Join -- this is outlined in one of the Project Real documents.
Larry
|||Larry,
Good point though even if parameterised queries could do the job I would still want to be able to use an expression. I seldom, if ever, use parameterised queries because expressions do the same job much much better.

-Jamie|||Jamie,
To me both your suggestions for Lookup(add AlwaysUseDefaultCodePage and make SqlCommand expressionable) are sensible and worth reconsideration -although to accomplish these, further details have to be carefully discussed. How about you raise them as DCRs so our triage can review and decide how to take care of both?

Thanks
Wenyang|||Thanks Wenyang,
I've submitted it via the product feedback centre.

People, if you want to vote for this to be done then go here: http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=5ee6da3e-4d8b-4ada-a526-1034c11d6763

-Jamie