I have a situation where I need to do an update on a very large set of rows that I can only identify by their ID (since the target records are selected by the user and have noth
I would use a table-variable / temp-table; insert the values into this, and join to it. Then you can use the same set multiple times. This works especially well if you are (for example) passing down a CSV of IDs as varchar. As a SQL Server example:
DECLARE @ids TABLE (id int NOT NULL)
INSERT @ids
SELECT value
FROM dbo.SplitCsv(@arg) // need to define separately
UPDATE t
SET t. // etc
FROM [TABLE] t
INNER JOIN @ids #i ON #i.id = t.id