This is a discussion on Sort Expression as Store Procedure Parameter? within the SQL Server forums, part of the Microsoft SQL Server category; --> Can I pass a sort expression into a store procedure as a parameter? I want to do sth like ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| ||||
| |