79159135

Date: 2024-11-05 12:37:59
Score: 1
Natty:
Report link

So I would structure it like this

IF @category = 0
BEGIN
    SELECT * FROM Articles WHERE Category = @category
END

EDIT:

You could also use a case statement as so:

select * from Articles where category = (
CASE WHEN @category= 0 THEN @category END)
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: OFNEILL