I have 2 tables
select * from snsystemcertification
where fiscalyear=2014

select * from SNLunchSevereNeeds
where HHFKOverride=1

I have to write a stored procedure from these tables I have to get systemcertification id

SELECT SFA.SystemCertificationID,SFA.FiscalYear
FROM SNSystemCertification AS SFA
INNER JOIN SNLunchSevereNeeds AS LS ON SFA.SystemCertificationID = LS.SystemCertificationID
WHERE SFA.FiscalYear=2014
--and SFA.SystemID=@SystemId
and LS.HHFKOverride = 1
and LS.HHFKProcess = 1
and LS.HHFKPayFrom = 7


This table is the eligible table SNLunchSevereNeeds (the idea is that what ever last year eligible this year also should be eligible)

need to find out like for all the systems who are eligible for current year!!

can anyone help like how to write a stored procedure.