Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 There was a thread on order by

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2003-12-10 : 08:40:21
There was a thread on "ORDER BY" recently which contained a post from Mr. Cross Join.

In that thread, there was an example of toggling the ASC / DESC by setting one or the other to either NULL or '' similarly to..

ORDER BY
CASE WHEN @ASC = 1 THEN MyDate ELSE '' END ASC ,
CASE WHEN @ASC = 0 THEN MyDate ELSE '' END DESC

I'm getting a compile / parse time error using the above 'Duplicate columns cannot appear in ORDER BY, and I can't locate the original thread.

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-12-10 : 11:49:26
Is this the thread??

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=26925
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2003-12-10 : 12:40:56
Yep, that was the thread.

And the trick (from that thread) is to use a different constant in the ELSE clause of each CASE statement. (I had used '' for both CASE statements). This will defeat a SQL compiler validation check that's just trying to do it's job but is getting in the way.

Go to Top of Page
   

- Advertisement -