I am running the following query and checking whether it returns any results and if not I need implement some logic in my sp. I have given couple of code blocks below from my sp.
select * from temp
where (select * table1 where Id='4728')=0
If the table1 doesnt have any records it shouldn’t return any results and I need to know whether I am checking it correctly.
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)
Since you’re in a Stored Procedure and you may just want to do this