Using: SSMS 2008, t-SQL
Goal: Return results of query in the same order that I input them into the WHERE clause
Example:
select *
from LoanTable
where LoanNumber in (3,2,4,5,1)
Yes, the simplified query here runs, but the results are returned in the order 1,2,3,4,5. When instead I would like them to be returned in the order 3,2,4,5,1 (the order of input into the WHERE clause).
Additional Information: The reason for this is because I use a VBA loop in Excel to generate coversheets for each loan number typed into a column in an Excel workbook, and the cover sheets need to be generated/printed off in the order that the operator inputs them. This allows the operator to marry them with another corresponding document easily. But if the loan numbers come back from the SQL query in a different order, this marrying process becomes quite difficult when the operator is dealing with hundreds of coversheets generated.