Query is not searching for other tables for more records, it is searching for only one table and giving the result
Expected o/p :
| |||||||||||||||
Query Used :
create table #temp (CRMguid Nvarchar(50))
insert into #temp(crmguid) values (77),(2),(2)
Go
if exists (select COUNT(1) from employeinfo.dbo.emp where empid in ( select * from #temp))
begin
(select * from employeinfo.dbo.emp where empid in ( select * from #temp))
end
else if exists (select count(1) from employeinfo.dbo.emp1 where eid in ( select * from #temp))
begin
select * from emp1 where eid in ( select * from #temp)
End
else if exists (select count(1) from employeinfo.dbo.emp1 where eid in ( select * from #temp))
begin
select * from employeinfo.dbo.employee where id in ( select * from #temp)
end