1

I am trying to migrate my 2008 DB to 2019 using Data Migration Assistant. Unfortunately Ii have an Unqualified Join (Behavior Changes) in a Procedure and I can't figure out how to fix it.

Here is the code:

FROM Codebar
INNER JOIN Codebar_IdentPag ON Codebar_IdentPag.Tipo = Codebar.Tipo,  
Account
INNER JOIN AccountName ON AccountId = Account.Id 
LEFT JOIN AccountType2 ON AccountType2.Codigo = AccountType2Cod  
LEFT JOIN AccountType ON AccountType.Codigo = AccountTypeCod  
LEFT JOIN AccountPlan ON AccountPlan .Codigo = AccountPlanCod 
LEFT JOIN Currency ON Currency.Codigo = CurrencyCod
LEFT JOIN Country Country1 ON Country1 .Codigo = CountryCod
WHERE Account.Id = @numAccount  
AND Codebar.Id = @idCodebar  

I think the problem occurs at the first INNER JOIN

What might be the cause of my problem?

  • I suspect you have a typo and `Codebar_Identpagon` is actually `Codebar_IdentPag ON`. With that your query makes some sense as `INNER JOIN Codebar_IdentPag on Codebar_IdentPag.Tipo = Codebar.Tipo CROSS JOIN Account INNER JOIN AccountName on AccountId = Account.Id`, where the `CROSS JOIN` (which is the unqualified one) likely should be replaced by a more specific join between `Account` and `Codebar` (or other tables) that should be supplied in the `WHERE` that you're not showing here. – Jeroen Mostert Jan 09 '20 at 14:54
  • Thanks for the reply man! I wrote the WHERE Statement that was missing – João Godinho Jan 09 '20 at 15:16
  • OK, that's a real `CROSS JOIN` as the row selected from `Account` depends only on a parameter and not the other tables. It could alternatively be written as a `CROSS APPLY` (`CROSS APPLY (SELECT ... FROM Account JOIN ... JOIN ... WHERE Account.ID = @numAccount) AS AccountData`) for clarity since all the other `JOIN`s are related to `Account` and not anything in `Codebar`, but the code analysis ought to be content with merely a `CROSS JOIN`. – Jeroen Mostert Jan 09 '20 at 15:22

1 Answers1

1

Your JOIN syntax bit vogue, just fix it :

FROM Codebar cb INNER JOIN
     Codebar_IdentPagon IP 
     ON IP.Tipo = Tipo INNER JOIN
     Account A
     ON < whatever mapping you have > INNER JOIN
     AccountName AN
     ON AN.AccountId = A.ID
Yogesh Sharma
  • 49,870
  • 5
  • 26
  • 52