I want SQL server to connect multiple tables vertically

Asked 1 years ago, Updated 1 years ago, 104 views

I have a question about the SQL table.
[What I want to do]
I want to connect all the tables (columns, etc.) vertically on SQL server
(You can use UNION, but if you have 100 tables, for example, it's troublesome to write one by one)

[Details]

Current daily log data (Excel, 100000 lines/day) [20171015], [20171016] and [20171017] are stored in Excel sheet. We import these sheets into SQL server in bulk.

With this method, the table is only as many sheets (i.e., days) on the SQL server.
created.

From here on, when we analyze monthly and yearly,
I'd like to connect all those sheets vertically so that they can be loaded at once.

The method of using UNION clauses requires UNION as many sheets as possible. It's very difficult to write (it's troublesome) and it doesn't look good.

If anyone knows a good way, please let me know.

sql sql-server

2022-09-30 19:27

2 Answers

I feel that the root of the problem is that it is divided into tables when registering.Why don't you export Excel to CSV and import it into one table?Macros, etc. will help you automate, and you don't have to rewrite queries every month.


2022-09-30 19:27

The method of using UNION clauses requires UNION as many sheets as possible. It's very difficult to write (it's troublesome) and it doesn't look good.

Instead of writing SQL statements directly, why don't we generate them with macros?

In general, partition table is used to divide into one table.


2022-09-30 19:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.