473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Sort Expression as Store Procedure Parameter?

Can I pass a sort expression into a store procedure as a parameter? I
want to do sth like the following but do not know if it's possible.
Maybe I need some tricks to work around?

CREATE Procedure SelectAllRoles
(
@SortExpression varchar(20)
)
AS

IF @SortExpression <> ''
THEN

SELECT Id, Name, Name2, LastUpdated
FROM [Role]
ORDER BY @SortExpression

ELSE

SELECT Id, Name, Name2, LastUpdated
FROM [Role]

GO
Thanks!
Zhu Ming

Jul 23 '05 #1
1 1993

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alessandro | last post by:
Hi, here is the problem... I must create a store procedure that do the following... 1. select id_name,...'some other field' from table 'data' where 'criteria' = @parameter 2. use the result...
10
by: Jozef de Veuster | last post by:
Hi, I'm trying to create a Stored Procedure that returns a recordset, but I want to be able to choose the ORDER BY clause in mijn parameter list of the Stored Procedure. Since CASE .. WHEN can...
0
by: Mainlander | last post by:
I have a class that I designed that contains some objects in its fields, that are derived from the TList class. I want to use the TList Sort procedure to sort the items that are in the derived...
1
by: Hugo Lefevre | last post by:
Dear, I have a problem : I have a database which contains my data of hardware. The Id is a varchar and I want at my filling form that my user know which is the last one. So I made a store...
0
by: kids_pro | last post by:
Hi there, I create a store procedure call GetPayment(@dtFrom DATETIME, @dtEnd DATETIME) After that I design a report using that store procedure I select crystal report in this case. I can...
3
by: Dj | last post by:
If you passed all of the fields as one group level when you rejester the SP you would only be able to use one CHAR field. Now here is the rub. If you are passing mix data, why not send it in the...
6
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like...
5
by: Alan T | last post by:
Currently our SQL Server 2000 database table field is using char to store as boolean, ie. "T" or "F". Now we change the field from char to bit field. I am not sure how it has impact on the C#...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.