Combine multiple CSV files on SQL Server

91zkwejq  于 2023-06-21  发布在  SQL Server
关注(0)|答案(1)|浏览(130)

The dataset I'm working with are saved as different files for each month, how to I join these files together in SQL Server. I tried using Excel and Power Query but the datasets are too large and wasn't able to load completely.

I tried to google how to do this online but all I got was just how to import CSV files to SQL Server.

sycxhyv7

sycxhyv71#

Try to import each file into a separate table and create a table for each month's data. You can use the Import/Export Wizard, BULK INSERT statement, or an SSIS package.

Once imported, you can use the join statement to combine the data as mentioned below :

SELECT *
FROM Table_January
JOIN Table_February ON Table_January.ID = Table_February.ID
-- Add more JOIN clauses for additional months if needed

This will combine the rows from Table_January and Table_February based on the matching ID values.

相关问题