Link to home
Create AccountLog in
Avatar of wlevy
wlevy

asked on

Custom sort for SQL Server

I need to modify a stored procedure which normally returns rows (where the selection is filtered by a parameter) sorted by ItemName. The new requirement is that if any of the returned rows has ItemName with a certain value (let's say, "Hello" for example), that should be returned as the first row, and the rest of the rows to be returned must be sorted by ItemName.

If records to be returned are:
An Item
Broccoli
Hello
Portugal

Then the stored procedure should return:
Hello
An Item
Broccoli
Portugal

This must also work if "Hello" is not one of the returned values.

Thanks for your help!
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of wlevy
wlevy

ASKER

Thanks!