Sorting Stored procedure using a parameter

Sorting Stored procedure using a parameter

Post by Hill » Thu, 01 Mar 2001 12:16:55



Hi RGP:
The following example will demonstrate the concepts you will need to make this a
working proc:

use pubs
Go
Create Procedure GetActiveStaff


AS







go
Exec GetActivestaff 'au_lname','desc'
Exec GetActiveStaff 'au_fname', 'asc'
Drop Procedure GetActiveStaff

Cut and paste this proc in QueryAnalyzer to view its action.
Hope this helps.
Bob


> I am trying to populate and asp page with Employees so that the page can be
> sorted Ascending or Descending by First Name, Last Name, or Office.

> I have tried (without much success) to write a stored procedure that takes 2

> +---------------------------------------------------------------------------
> ---
> CREATE PROCEDURE [GetActiveStaff]


> AS

> SELECT EmployeeID, FName, LName, Active, Office, OfficeID, RGPOffice.Alias
> FROM Employee, RGPOffice
> WHERE (Active = 1)
> AND Employee.Office = Office.OfficeID

> When "FName" Then FName
> When "LName" Then LName
> When "Office" Then Office
> END
> GO
> +---------------------------------------------------------------------------
> ---



> Any help or pointers as always would be very much appreciated.

> Kind Regards

> Ian James