Hi i have a store procedure, where i do a select query.
I want order this by an external parameter.
I post an minimal example:
CREATE PROCEDURE [dbo].[up_missioni_get_data]
@order VarChar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT * from missioni ORDER BY ...
END
What can i write in order by for do that?
thanks
You have 2 options, either use a CASE statement, or use dynamic sql
This would be an example of the CASE statement
And this would be and example of dynamic sql