我有一个存储过程,它调用 2 个其他存储过程来获取一些值。
ALTER PROCEDURE [dbo].[Delivery_SelectByJobID]
(
@job_ID int
)
as
-- if possible - if count(pods) > 0 return true
-- and if count(photos) > 0 return true
declare @podCount int = 0;
declare @photoCount int = 0;
EXEC @podCount=countPodsForJob @job_ID
EXEC @photoCount =countPhotosForJob @job_ID
declare @podsBit bit=0
declare @photosBit bit=0
if @podCount > 0
begin
set @podsBit = 1
end
if @photoCount > 0
begin
set @photosBit = 1
end
SELECT Job_Reference_No, Job_Start_Date, Job_POD_Filename, Job_Photo_Filename,
Job_Signed_For_Name, Job_ID, Job_Status, Job_Delivery_Notes, @podsBit as Job_POD_Supplied,
@photosBit as Job_Photo_Supplied
FROM Jobs
WHERE (Job_ID = @Job_ID) AND (Job_Status <> 7)
当我运行它时,它返回 3 组结果,即 Count_pods、Count_Photos 和选择的结果。我只想返回选择的结果。如何停止返回其他结果?