>> order by

  • Thread starter Thread starter Jonathan
  • Start date Start date
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
 
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)
 
ahh I did not think of that, I was trying

.... Order by @p

with @p passing the column number.

Many thanks,
Jonathan
 
我这个东西怎么都æžä¸å¥½æ ·å­å“¦...
 
Back
Top