Hi All,
Trying to figure out the best way to re-write a query to avoid this Warning
"Type conversion in expression (CONVERT(nvarchar(50),[Union1008],0)) may affect "CardinalityEstimate" in query plan choice"
with [ReferralSource] as(
select
[ReferralSource]
from
[PlatformDM_Stage1].[UserData]
union
select
[ReferralSource]
from
[PlatformDM_Stage1].[SessionData]
)
select
CampaignKey = convert(nvarchar(50), [ReferralSource])
from
[ReferralSource]
Referral source is a varchar(50) column in both staging tables and this query is being used in SSIS dataflow to load up new values into MDS. Since the MDS staging table destination expects nvarchar, I convert it in my source query.
I can't quite understand why does this warning come up, since cardinality should have been determined way before the last Compute Scalar step. The best I've been able to come up with is doing convert(nvarchar(50), [ReferralSource] + '') - but it seems like too much of a hack. I would appreciate your thoughts on why this happens and what's the correct way of formulating this query to avoid the warning.
Regards,
Aleksandr Krymskiy