Is it possible to have to ORDER BY statements in the same stored
procedure?
I am trying to use the same stored procedure for two different pages
but the data returned needs to sorted DESC on one page and ASC on
another. Below is my SP:
CREATE procedure sp_getLeads
@p_SortType int,
@p_PropID int
AS
SELECT ID, PropID, Name, Status
FROM Leads
WHERE PropID = @p_PropID
IF @p_SortType = '1'
(ORDER BY DateCreated DESC)
ELSEIF @p_SortType = '2'
(ORDER BY DateCreated ASC)
END
RETURN 1
GO
Can someone tell me what I am doing wrong?