Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 24th, 2003, 04:34 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Dynamic Sort Order


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway