B"H
Steve,
The case statment is actualy made to handle more than one posibility. The
statment you gave Aaron is realy a variation of the way case was meant to
work, which would be cleaner and better for this situation:
WHEN 1 Then
a
WHEN 2 Then
b
END
> You don't need dynamic SQL here. You can do the following:
> ORDER BY
> along with the value you want to order by.
> Steve Kass
> Drew University
> > hello
> > I have a table T with columns a, b, c, d, e
> > I wrote a simple stored procedure that does a SELECT on T and takes a
search
> > text parameter ...
> > CREATE PROCEDURE foo
> > AS
> > GO
> > it worked great.
> > Next I wanted to add another parameter to this to control an ORDER BY
clause
> > in the query.. ie given a number from 1 thru 5, I want the result set
to be
> > sorted by one of the corresponding columns (a thru e)
> > I suppose I could have a series of five IF statements that invoke five
> > seperate copies of the SELECT staetement , each with a different ORDER
BY
> > clause(but in paractice my actual query is huge and managing this amount
of
> > duplicated text would be a nightmare), so what I'm really looking for is
a
> > clever piece of syntax that I can use to parameterize this ORDER BY
clause
> > from within the stored procedure...
> > any ideas?
> > thanks
> > A