在sql Server 2012中使用以下查询获取此错误.
在“RETURN”附近的预期条件的上下文中指定的非布尔类型的表达式.
CREATE FUNCTION [dbo].[GetPMResources](@UserResourceNo nvarchar(250)) RETURNS @Resources TABLE ( ResourceNo nvarchar(250) COLLATE Latin1_General_CS_AS not null,Name nvarchar(250) COLLATE Latin1_General_CS_AS not null ) AS BEGIN Declare @RoleID int,@UserDivision nvarchar(20) SELECT TOP(1) @RoleID = r.ReportingRole,@UserDivision = r.DivisionCode FROM Resource r WHERE r.ResourceNo = @UserResourceNo INSERT @Resources SELECT r.ResourceNo,Name = r.ResourceNo + ' ' + r.Name FROM Resource r WHERE r.ResourceNo IN ( SELECT m.ResourceNo FROM JobMember m JOIN Job j ON j.JobNo = m.JobNo WHERE j.ProjectManagerNo = @UserResourceNo OR j.AlternateProjectManagerNo = @UserResourceNo ) OR ( SELECT m.ResourceNo FROM JobMember m JOIN JobTask t ON t.JobTaskNo = m.JobTaskNo WHERE t.TaskManagerNo = @UserResourceNo OR t.AlternateTaskManagerNo = @UserResourceNo ) RETURN END