General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
I'm just starting to work with SQLServer7 and have a basic question regarding ordering the result set within stored procedure from a passed parameter. The application is web based and I am allowing the users to sort data by clicking on the column header in my ASP page. This simple SP is below. All I am trying to do is use a SP and allow user to change the sort order by passing in a parameter to be used in the order by clause. If anyone can help I sure would appreciate. Thanks.
John.
CREATE PROCEDURE ProspectEntries @closedstat bit = 0, @recsort char(15) = 'p_city'
AS
SELECT prospects.prospect_id, prospects.prop_id, LOWER(prospects.address) address,
LOWER(prospects.p_city)+ ' ' City, RTRIM(LOWER(users.fname)) Firstname,
RTRIM(LOWER(users.lname)) LastName, RTRIM(LOWER(users.lname)) queryby,
prospects.checkeddate querydate, prospects.processed , prospects.comments,
prospects.processedby, prospects.processeddate
FROM prospects INNER JOIN users ON prospects.checkedby = users.keyid
WHERE processed = @closedstat
ORDER BY @recsort
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only