CREATE procedure testProcedure(@suid integer,@schyear integer)
as
begin
create table #temptable(
SUID INTEGER NULL,
SCHYEAR INTEGER NULL,
EVENTID INTEGER NULL,
EVENTCODE VARCHAR(30) NULL,
ANTECEDENCE VARCHAR(30) NULL,
ADDENDUM VARCHAR(30) NULL,
ACTCODE VARCHAR(30) NULL
)
insert into #temptable
select SUID,SCHYEAR,EVENTID,EVENTCODE,ANTECEDENCE,ADDENDUM,ACTCODE
FROM TB_NAA_EVENTOFFERED
where
SUID = @suid and SCHYEAR = @schyear
declare @tempschyear integer
set @tempschyear = @schyear
IF @tempschyear = 2015
select * from #temptable
else
select * from TB_NAA_EVENTOFFERED
end;