I gave you your answer a day or so ago.
This is NOT the proper way to write this sql query. You should do it this way:
Select A.GroupName ,
B.Brand ,
B.Model ,
B.SerialNo ,
B.Status ,
B.AddedOn
FROM GroupDetails AS A
INNER JOIN DeviceDetails AS B ON A.GroupId = B.GroupId
WHERE B.Status LIKE @status OR @status = ''
Furthermore, if it were me, I'd give the @Status parameter a default value of ''. That way, I could call the proc with no parameters and still get records back.
This will return all records that match the current value of
@status
, or if @status is an empty string, returns all records. Furthermore, you should probably use
LIKE
instead of "=" in the
WHERE
clause because you can't guarantee the case will match.