Brian
asked on
Need help with Stored Procedure
Hello Experts,
I have the following Stored Procedure below that I need to retrieve ALL data based on the ghaoc_id value entered even if the value ghaocp_id is NULL from the HealthCourses_CourseSchedu les table.
The attached Excel spreadsheet includes all Database schema along with real data that is in my system. You will see that I have NULL values for the ghaocp_id in the HealthCourses_CourseSchedu les table. I still need to display ALL to the user even if ghaocp_id has NULL value.
I'm also attaching my current Stored Procedure that I'm having the trouble with.
Thank in advance!!
I have the following Stored Procedure below that I need to retrieve ALL data based on the ghaoc_id value entered even if the value ghaocp_id is NULL from the HealthCourses_CourseSchedu
The attached Excel spreadsheet includes all Database schema along with real data that is in my system. You will see that I have NULL values for the ghaocp_id in the HealthCourses_CourseSchedu
I'm also attaching my current Stored Procedure that I'm having the trouble with.
Thank in advance!!
STORED PROCEDURE:
ALTER PROCEDURE [dbo].[TEST2]
(
@ghaoc_id int
)
AS
SELECT cs.ghaoc_id, oc.ghaco_name, cs.ghaocp_id, cs.csch_startdate, cs.csch_starttime, cs.csch_endtime, hi.hmi_name, p.ghaocp_name
FROM HealthCourses_CourseSchedules AS cs
INNER JOIN HealthCourses_HighmarkInstructors AS hi
ON cs.hmi_id = hi.hmi_id
INNER JOIN HealthCourses_GeneralHealthAwarenessOneCoursesPrograms AS p
ON cs.ghaocp_id = p.ghaocp_id
INNER JOIN HealthCourses_GeneralHealthAwarenessOneCourses AS oc
ON cs.ghaoc_id = oc.ghaoc_id
WHERE cs.ghaoc_id = @ghaoc_id
ORDER BY ghaocp_name ASC
Book1.xls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER