1
    `IF(@ParentField = 'Reason for call - Primary Issue')
    BEGIN
        DELETE FROM dbo.ControlBrandMapping CBM
            INNER JOIN dbo.ControlManagement CM ON CM.ID = CBM.CONTROLID
                WHERE CM.DefaultName = 'Reason for call - Sub Issue' AND CBM.BRANDID = @BrandId
    END`

我尽力让它看起来尽可能整洁。我收到此错误 - “'CBM' 附近的语法不正确。” 请帮忙

4

2 回答 2

2

您在子句CBM后缺少别名。DELETE试试这个:

    DELETE CBM
    FROM dbo.ControlBrandMapping CBM
    INNER JOIN dbo.ControlManagement CM ON CM.ID = CBM.CONTROLID
    WHERE CM.DefaultName = 'Reason for call - Sub Issue' 
      AND @ParentField = 'Reason for call - Primary Issue'
      AND CBM.BRANDID = @BrandId
于 2012-12-02T13:18:21.473 回答
0

我不确定,我刚开始,但据我所知,在进行连接时,我认为应该INNER JOIN dbo.ControlManagement CM ON (CM.ID = CBM.CONTROLID) 注意括号,但我可能错了

于 2012-12-02T13:18:19.820 回答