problem in making stored procedure
Hello friends
I am with task to make a time table.In that I want to assign teacher for particular class. In class registration i have registered a classes based on fromyear(2012) and Toyear(2013) as a academic year.my doubt is suppose i want to select classes in the academic year(2012-2013)based on the current year in sql queries then from janaury to march would get next year class details.how to avoid rectify this problem.
My stored procedure for getting class below. its work fine for upto december then from january it gives the next year class detail.
<pre lang="sql">alter procedure sp_addstandered
as
begin
declare @fromyear int,@toyear int
set @fromyear=convert(int,datepart(year,getdate()))
set @toyear=@fromyear+1
select Standered_name from Standered_details where Acadamic_year_id=(select Acadamic_year_id from Acadamic_year where Acadamic_year_from=@fromyear and Acadamic_year_to=@toyear)
end</pre>