The following code in the query analyzer gives me an error:
Can someone tell me what I am doing wrong please?
Code:
Server: Msg 156, Level 15, State 1, Procedure searchDynamicContent, Line 18
Incorrect syntax near the keyword 'ORDER'.
Code:
CREATE PROCEDURE searchDynamicContent
@dynamicArea VARCHAR(25),
@dynamicTitle VARCHAR(50),
@dynamicOrder int
AS
SELECT *
FROM dynamicContent
WHERE dynamicContentArea = @dynamicArea
AND dynamicContentTitle LIKE '%' + @dynamicTitle + '%'
AND dynamicContentStatus != 'DELETED'
if (@dynamicOrder = 1)
begin
ORDER BY dynamicContentTitle ASC
end
GO