sql - Conversion failing when changing join constraint from list of varchars to subquery -


i'm trying update procedure run switching out list of static varchars within in statement (which in join condition) use subquery instead. however, i'm getting error saying conversion failed when converting varchar value 'normal' data type int.

i know means somewhere in query i'm trying convert value 'normal' int, in query there's not place should int - it's varchar or datetime, , subquery returns same values former static list of varchars. furthermore, there's not place anywhere in dataset value "normal", confuses me.

has else dealt before?

edit:
here's code (reduced show pieces causing error):

select * #temptable     left join dbo.v_lookup_assumptions assumptions on      case when group3 in      --('value1', 'value2', 'value3')      (select lookupdetail_name  lookupdetail)     group3 else group2 end =assumptions.sector2     , asofdate between assumptions.startdate , assumptions.enddate     , shortname = assumptions.assumptionshortname 

i can comment out subquery , uncomment list of values , works. also, if don't run "shortname" constraint when i'm using subquery, works (though doesn't give expected results, might expect). join constraints either varchar or date.

in addition, added 'normal' list of static values , ran expected. updated subquery select 'value1' lookupdetail , failed.

edit2:
, makes no sense, if limit original #temptable 2080 records, new subquery syntax works. however, if let go 2081 records fails - regardless of dataset. in other words, change dates around different data each time through , limit #temptable 2080 records, new syntax works fine. change 2081 records , fails. if run through 2081 record dataset , filter clause, can every row in 2081 record display long it's not 2081 @ same time.

it turns out execution plan changing when total number of records exceed 2080, , implicitly converting varchar field int. grabbed xml query plan small dataset sql server profiler , forced larger dataset query use option (use plan '<insert xml query plan here />').


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -