|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pass a parameter for sort order
Is there a way to pass a parameter into a stored procedure to set the sort order.
I have tried things like ORDER by EmployeeID @direction where @direction is a varchar with a value of 'desc' and I get an error. I do not want to dynamically create the sql and use sp_executesql. I have already done it this was but I am looking for a better solution. |
|
#2
|
|||
|
|||
|
Code:
order by case when @direction = 'asc' then Employeeid end , case when @direction = 'desc' then Employeeid end desc |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Pass a parameter for sort order |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|