i have the following Query , i built it in sql server 2008 query builder
(SELECT CourseNo
FROM ppu_RegistrationInfoDetailes
WHERE (StudentNo = @StudentNo) AND (SemesterNo =
(SELECT TOP (1) SemesterNo
FROM ppu_RegistrationInfo AS ppu_RegistrationInfo_1
WHERE (StudentNo = @StudentNo)
ORDER BY AcademicYear DESC)) AND (AcademicYear =
(SELECT TOP (1) AcademicYear
FROM ppu_RegistrationInfo AS ppu_RegistrationInfo_1
WHERE (StudentNo = @StudentNo)
ORDER BY AcademicYear DESC)))
This query will return the Course number of the registered course for the current semester
when i execute it , in query builder it execute correctly
when i create a stored producer for this query no rows affected
this is my stored producer
(ALTER PROCEDURE CurrentSemesterCourses
@StudentNo int
AS
DECLARE @Semester int
DECLARE @AcademicYear int
SET @Semester = (SELECT TOP (1) SemesterNo
FROM ppu_RegistrationInfo AS ppu_RegistrationInfo_1
WHERE (StudentNo = @StudentNo)
ORDER BY AcademicYear DESC)
Set @AcademicYear =(SELECT TOP (1) AcademicYear
FROM ppu_RegistrationInfo AS ppu_RegistrationInfo_1
WHERE (StudentNo = @StudentNo)
ORDER BY AcademicYear DESC)
SELECT CourseNo
FROM ppu_RegistrationInfoDetailes
WHERE (StudentNo = @StudentNo) AND (SemesterNo =@Semester) AND (AcademicYear =@AcademicYear))