Suppose you have a query that looks like so:
SELECT * FROM client
WHERE identifyingnumber LIKE '%86%'
Sometimes there might be an exact match, meaning the identifyingnumber is 86. What’s the best way of making the record with that exact match to the top of the query?
Consider that the exact match must be the shortest in string length of all the matches.
This will be a CPU-high query because of the LEN operation. You might consider creating a column for the length of identifyingnumber in the client table – possibly as a calculated column – to save some CPU on the select.
As for what is best– It kind of depends on your system. The UNION option offered by Paolo was the first thing that came to mind for me, too, except that requires handling two different parameter values, assuming you parameterize your queries (as I always do).