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.
| Author |
Topic |
|
overbored
Starting Member
12 Posts |
Posted - 2002-01-18 : 21:36:24
|
| How do you go about sorting the data that a stored procedure selects? Or an even broader question is: how do you do *anything* with a table that a stored procedure selects? Please tell me this is possible!FYI I've tried:- stored_proc params ORDER BY blah- EXECUTE stored_proc params ORDER BY blah- (stored_proc params) ORDER BY blah- (EXECUTE stored_proc params) ORDER BY blah- SELECT stored_proc params ORDER BY blah- SELECT EXECUTE stored_proc params ORDER BY blah- SELECT (stored_proc params) ORDER BY blah- SELECT (EXECUTE stored_proc params) ORDER BY blah |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
|
|
overbored
Starting Member
12 Posts |
Posted - 2002-01-18 : 22:45:30
|
| This will work for me, but I can't get descending sort to work. Whenever I add a DESC to the end of the sort column name in the CASE statement, T-SQL tells me there's a syntax error. I tried putting the result expression in quotes, but to no avail. In fact, I think it would only work with one-word result expression. Any tips? |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-01-18 : 22:48:34
|
| you can doselect *from tblorder by col1 desc, col2 descbut not select *from tblorder by case @i when 1 then col1 desc else col2 desc end to do this you need something likeselect *from tblorder by case @i when 1 then col1 else 1 end desc ,case @i when 2 then col2 else 1 end desc==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy.Edited by - nr on 01/18/2002 22:49:08 |
 |
|
|
|
|
|