I want to sort the results of this query in SQL Server:
SELECT *
FROM t1
WHERE t1.my_field_name IN ('val1', 'val2', 'val3');
...so that I get the results sorted in the same order as the IN list values.
In mySQL this can be done easily:
SELECT *
FROM t1
WHERE my_field_name IN ('val1', 'val2', 'val3')
ORDER BY FIELD(my_field_name, 'val1', 'val2', 'val3');
...but I don't know how to do it in SQL Server. Any suggestion?