I am operating on a MSSQL 2005 da开发者_JAVA技巧tabase system that has many stored procedures. One of the stored procedures is a "report" and I want to sort it without editing the stored procedure. Is there a way to sort the results of a stored procedure on the fly : something like this:
exec spReport 
order by ColumnT
You can insert into a temporary table. Then, sort from table.
e.g.
INSERT INTO #table
EXEC spReport
SELECT *
FROM  #table
ORDER BY ColumnT
No, you cannot do this. If you know the structure of the resultset, you can build a #tmp table first, insert #tmp exec spReport, then select from the #tmp table with an order by clause. You may even be able to hack something together using OPENQUERY or OPENROWSET, but I would recommend editing spReport either to always use the order you want or to take a parameter and define the order based on the parameter.
You should fill a temporary table with the result and then sort it. Here is the link showing how to do the first part:
How to SELECT * INTO temp table FROM Stored Procedure
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论