Answer the question
In order to leave comments, you need to log in
How to merge a large number of tables?
Hello! Help solve the problem.
I have 70 tables (each table belongs to one store). There are 70 shops in total. Each of them has the following fields: product code, product name, product quantity, price, etc. I need to write a procedure that will join all tables so that I can make a query, for example, displaying all products from all tables and their prices.
I can, of course, join them all via UNION, but I would prefer a query using a list of all tables, something like this:
SELECT product name, price FROM (
SELECT name FROM sys.tables
WHERE name LIKE '...%' OR name LIKE '...%' ...)
How, in principle, to work with such a large number of tables?
Thank you in advance for your help!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question