I am given a list of table names and would like to get the distinct values of a specific column from each of these tables. For example:
Input = TableA, TableD, TableX
Output =
Table Name | Value
TableA | 1
TableA | 2
TableD | 1
TableX | 3
Since these tables are unrelated, it would be great if I could query them in parallel to save some time. I think querying them in one large UNION statement will let the SQL Server engine automatically parallelize the query, but I'd like to avoid this. Some of these tables are large, and it's possible querying them might fail on occasion due to memory/resource issues. So if I did a UNION, one table failing will result in the entire query failing.
Is my only option to handle this on the application side? (i.e make parallel calls to the same sproc for each table in the input list)
Thanks for any help and please let me know if the goal is unclear.