Sql server 我正在更新一些旧的SQL代码,在将*=运算符更新为左外部联接时出错

Sql server 我正在更新一些旧的SQL代码,在将*=运算符更新为左外部联接时出错,sql-server,outer-join,legacy-code,Sql Server,Outer Join,Legacy Code,我得到一个错误: MSG 4145:在预期条件的上下文中指定的非布尔类型的表达式,靠近“Left” 想法 USE [DatabaseName] GO /****** Object: StoredProcedure [dbo].[spFilePlanNavigate] Script Date: 03/19/2015 14:54:45 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo]

我得到一个错误:

MSG 4145:在预期条件的上下文中指定的非布尔类型的表达式,靠近“Left”

想法

USE [DatabaseName]
GO
/****** Object:  StoredProcedure [dbo].[spFilePlanNavigate]    Script Date: 03/19/2015 14:54:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER Procedure [dbo].[spFilePlanNavigate](@CategoryId int) 
As 
Set NoCount On
Begin
    If @CategoryId > 0
        Select FilePlan.*, Retention.Retention_Type, Retention.Retn_Description1 
            From FilePlan, Retention 
            Where FilePlan.Retention_Code Left Outer Join Retention.Retention_Code 
                And FilePlan.Category_Id = @CategoryId
    Else
        Select FilePlan.*, Retention.Retention_Type, Retention.Retn_Description1 
            From FilePlan, Retention 
            Where FilePlan.Retention_Code Left Outer Join Retention.Retention_Code 
                And FilePlan.Category_Id_Parent = @CategoryId
End

左外部联接的语法如下:

select cola, colb from table1 left outer join table2 
on table1.id = table2.id 
where table.catid = @catid
您的sql语句缺少“on”子句。“on”子句告诉sql Server匹配列出的列上的行