我正在运行以下查询并检查它是否返回任何结果,如果没有,我需要在我的 sp.xml 中实现一些逻辑。我从我的 sp 中给出了下面的几个代码块。
select * from temp
where (select * table1 where Id='4728')=0
如果 table1 没有任何记录,它不应该返回任何结果,我需要知道我是否正确检查它。
INSERT INTO #companies
SELECT DISTINCT c.Company_Id
FROM COMPANY C
INNER JOIN Request_Summary rs ON c.Company_ID=rs.Company_ID
WHERE
rs.IsMember_Ind <> 0
AND (SELECT COUNT(*) FROM Monitor_Request mr WHERE mr.Company_ID=c.Company_ID)< 5
-- I am checking it here
AND EXISTS(SELECT COUNT(*) FROM Monitor_Request mr2 WHERE mr2.Company_ID=c.Company_ID)
AND NOT EXISTS(
SELECT * FROM TaskAction ta WHERE
ta.FirstActionTypeId = @firstActionTypeId and
ta.TaskTypeId = @taskTypeId and
ta.NextActionTypeId is not null and
ta.EntityId = c.Company_ID and
ta.EntityTypeId = 1)