I am writing a stored procedure that will return a record set via ADO.
I want to vary the ORDER BY clause based on a parameter that I will pass in.
ie
If @parm= 1 Select blahblahblah Order by Fld1
If @parm= 2 Select blahblahblah Order by Fld2
If @parm= 3 Select blahblahblah Order by Fld3
Other aspects of the Select are always identical, just the Order By changes.
I wonderif this will screw up the execution plan; should I make three SPs instead?
Any thoughts?
I want to vary the ORDER BY clause based on a parameter that I will pass in.
ie
If @parm= 1 Select blahblahblah Order by Fld1
If @parm= 2 Select blahblahblah Order by Fld2
If @parm= 3 Select blahblahblah Order by Fld3
Other aspects of the Select are always identical, just the Order By changes.
I wonderif this will screw up the execution plan; should I make three SPs instead?
Any thoughts?