check this
select distinct
sm.EmpCodeC,sm.EmpNameC,
Isnull((select count(UserId) from CanteenLogs where TimeEntry between '01/Oct/2014 09:00:00 AM' and '01/Oct/2014 10:00:00 AM' and userId='20'),0) as 'BreakFast'
from CanteenLogs as rd inner join StaffMaster as sm on rd.UserID=sm.UserIdN and rd.UserID='20
and this when no record returned
select distinct
sm.EmpCodeC,sm.EmpNameC,
Isnull((select count(UserId) from CanteenLogs
where TimeEntry between '01/Oct/2014 09:00:00 AM' and '01/Oct/2014 10:00:00 AM' and userId='20'),0) as 'BreakFast'
into #tempfile
from CanteenLogs rd inner join StaffMaster sm on rd.UserID=sm.UserIdN and rd.UserID='20'
IF Exists (select top 1 * from #tempfile)
select * from Outputdata
else
select '' EmpCodeC ,'' EmpNameC ,0 BreakFast