Using composite fields in a JOIN

I'm using 2 fields for this JOIN and it runs a little slow :

UPDATE Nop_ProductVariant
SET OldPrice = recommended_price, ProductCost = cost, . . .
FROM Nop_ProductVariant  

 ((Nop_ProductVariant.ManufacturerPartNumber) + (CONVERT(nvarchar(50),Nop_ProductVariant.DownloadActivationType))) =
 (TopDawg.product_code + TopDawg.PID)

WHERE UnlimitedDownloads = 1

Is this ok or is there a better way of doing this?
Would taking there WHERE clause out help?      Thanks
LVL 16
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What indexes do you have on tables Nop_ProductVariant  and TopDawg?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
On SQL server management studio hit Display Estimated Execution Plan to see it sugests any index...

 Estimated execution plan button
But, by the looks of it, the Sums in the join clause don't seem a very good ideia...
Scott PletcherSenior DBACommented:
It's better to compare each column separately using AND rather than concatenate:

    Nop_ProductVariant.ManufacturerPartNumber = TopDawg.product_code AND
    Nop_ProductVariant.DownloadActivationType = TopDawg.PID

Forcing concatenation will really slow SQL down a lot.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Scott PletcherSenior DBACommented:
One of the reasons is that concatenation will prevent the use of existing indexes, even if they would normally be used.  The style above, with direct column comparisons joined by an AND, will allow existing indexes to be used, if applicable.
Any time you do a calculation like that in your WHERE clause, SQL performs at least one table scan.  If you you cannot join on the individual columns, then you should make a persisted computed column on the two fields, and index it.  That will allow for indexed lookups on your tables.
MikeMCSDAuthor Commented:
thanks all
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.