declare @RelevantMachines Table (MachineId int)
Select MachineId, ClusterId, MachineGuid, MachineName, RegisteredDate, MachineDetail, LastServiceCall, MachineType as MachineTypeId, ProductSetId
From PatchHub.Machine
Where ClusterId = @ClusterId
I would like to be able to return the select statement as a result set whilst at the same time populating the table variable with all of the returned rows MachineId values, this is in sql server 2008. How could you achieve this without running the select statement twice?