
January 24th, 2003, 04:34 PM
|
|
Up To His Eyes In Ads
|
|
Join Date: Oct 2002
Location: Chicago
Posts: 160
Time spent in forums: 1 m 25 sec
Reputation Power: 6
|
|
|
Dynamic Sort Order
I'm running a Stored Procedure with a dynamic sort order that looks a little something like this:
Code:
CREATE PROC sp_Data
(
@SortBy int
)
AS
SELECT Table1.* FROM Table1
ORDER BY
CASE @SortBy WHEN 1 THEN Field1 END,
CASE @SortBy WHEN 2 THEN Field2 END,
CASE @SortBy WHEN 3 THEN Field3 END,
CASE @SortBy WHEN 4 THEN Field4 END
, Field5, Field6
This works (yay!) but I'd like to make one of the @SortBy cases sort in a descending order but when I add the word "DESC" it bombs....
I don't want to form a dynamic SQL statement and execute it because I don't want tochange the permissions.
Any help is appreciated!
|