I have a list of record IDs for which I want to retrieve a single value from a table in SQL Server 2008.
My query is:
SELECT TestResult.FailureDetails FROM TestResult WHERE TestResult.ID IN (1,2,3,...)
The 'IN' expression contains hundreds of IDs. The ID column is the primary key of the table.
If my table is like:
ID Value
1 A
2 B
3 C
Will I always get results ordered by order of appearance in the 'IN' expression? If not, I am considering doing:
SELECT TestResult.ID, TestResult.FailureDetails FROM TestResult WHERE TestResult.ID IN (1,2,3,...)