【问题标题】:SQL Server 2008 Migration to 2019SQL Server 2008 迁移到 2019
【发布时间】:2020-04-27 04:50:53
【问题描述】:

我正在尝试使用 Data Migration Assistant 将我的 2008 数据库迁移到 2019。 不幸的是,我在程序中有一个不合格的加入(行为更改),我不知道如何解决它。

代码如下:

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  

我认为问题出现在第一个INNER JOIN

我的问题可能是什么原因造成的?

【问题讨论】:

  • 我怀疑你打错了,Codebar_Identpagon 实际上是Codebar_IdentPag ON。这样一来,您的查询就像INNER JOIN Codebar_IdentPag on Codebar_IdentPag.Tipo = Codebar.Tipo CROSS JOIN Account INNER JOIN AccountName on AccountId = Account.Id 一样有意义,其中CROSS JOIN(这是不合格的)可能应该被Account 和Codebar(或其他表)之间的更具体的连接所取代,应该提供在您未在此处显示的WHERE 中。
  • 感谢您的回复!我写了丢失的 WHERE 语句
  • 好的,这是一个真正的CROSS JOIN,因为从Account 中选择的行仅取决于一个参数,而不取决于其他表。为了清楚起见,它也可以写成CROSS APPLY (CROSS APPLY (SELECT ... FROM Account JOIN ... JOIN ... WHERE Account.ID = @numAccount) AS AccountData),因为所有其他JOINs 都与Account 相关,而不是Codebar 中的任何内容,但代码分析应该只满足于CROSS JOIN.

标签: sql sql-server-2008 database-migration sql-server-migration-assi


【解决方案1】:

你的 JOIN 语法有点流行,修复它:

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

【讨论】:

    猜你喜欢
    • 2010-12-18
    • 2011-06-23
    • 2011-06-09
    • 2011-03-31
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    相关资源
    最近更新 更多