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)
 Procedure that returns rows needs resorting by another procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-03-17 : 06:20:59
Paul Higgs writes "I have an SQL2000 stored procedure that basically fills up a declared table variable and ends with a 'Select * from @temptable order by col1'.

I need a second procedure that will return the results of the first one but reordered differently, how can I do this a 'select * from prc_Test order by col2' doesn't work? Should I try and pass the ordering as a parameter?

Thanks
Paul"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-03-17 : 06:51:24
You could pass the ordering as a parameter. Read more about order by in some of the articles on this site.

Otherwise, you will have to create another table and use the INSERT .... EXEC .... syntax to place the rowset from you first proc into this second table. The select form the second table.


Jay White
{0}
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-03-17 : 08:57:24
Also consider using a UDF -- you can select from them and order them as you like. As long as you aren't actually manipulating database objects (i.e., you are just SELECT'ing and/or creating table variables) stored procs are pretty easy to convert to user-defined functions.

- Jeff
Go to Top of Page
   

- Advertisement -