>> order by

J

Jonathan

Hi is it possible to pass a text variable to use as a sort column name as a
parameter for a stored procedure? so far my attempts are unsuccessful.

Many thanks,
Jonathan
 
S

Sylvain Lafontaine

You can add a Case statement to your order by:

.... Order by Case When @p = 1 Then 1 Else Column1 End;

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
 
J

Jonathan

ahh I did not think of that, I was trying

.... Order by @p

with @p passing the column number.

Many thanks,
Jonathan
 
Å

å¢å¼‚

我这个东西怎么都æžä¸å¥½æ ·å­å“¦...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top