developer77
Programmer
Hello everyone,
I have the following stored procedure that passes a @degree paramter:
CREATE PROCEDURE students_enrolled
(
@degree = null,
@ = null
)
AS
--
BEGIN
SELECT s.FirstName,
s.LastName,
s.MiddleName,
e.student_id,
e.degree
FROM tbl_Student s
left join tbl_Enrollment e on e.id = s.EnrollID
WHERE s.active_flg = 'Y'
AND e.degree LIKE CASE WHEN LEN(rtrim(ltrim(@degree))) > 0 THEN '%' + @degree + '%' ELSE e.degree END
RETURN
GO
In the database for tbl_Enrollment, sometimes the degree column is NULL. If the column is NULL, the records are not returned. Can you help me change this so that even when the values are NULL for degree, it still shows up the records and just displays the degree column as null?
Thanks
I have the following stored procedure that passes a @degree paramter:
CREATE PROCEDURE students_enrolled
(
@degree = null,
@ = null
)
AS
--
BEGIN
SELECT s.FirstName,
s.LastName,
s.MiddleName,
e.student_id,
e.degree
FROM tbl_Student s
left join tbl_Enrollment e on e.id = s.EnrollID
WHERE s.active_flg = 'Y'
AND e.degree LIKE CASE WHEN LEN(rtrim(ltrim(@degree))) > 0 THEN '%' + @degree + '%' ELSE e.degree END
RETURN
GO
In the database for tbl_Enrollment, sometimes the degree column is NULL. If the column is NULL, the records are not returned. Can you help me change this so that even when the values are NULL for degree, it still shows up the records and just displays the degree column as null?
Thanks