I have a query that passes in id's as a where clause and its failing at times as its timing out.
I've been advised to run the query in batches.
I'm not sure how to resolve this. in my where clause it uses
Where Id (1,4,5,3,8, etc etc) for hundreds of ids.
Can I run the query in batches and still output all results
why don't you input half your Id in one query and then save that as a temp table then run the other half of Ids as another query and save them into another temp table then union them ?
What version of SQL Server are you on? On 2012+ you can you the Offset Fetch clause to batch rows (although how much better this will be depends a lot on what your query actually does)