0

What is the best solution to transfer Excel and csv data from files to SQL Server tables and use trigger to automate it to other tables?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Check the following link https://stackoverflow.com/questions/40938557/fill-sql-database-from-a-csv-file – Yahfoufi Apr 13 '19 at 08:33

1 Answers1

0

The safest way would be to create an SSIS job for reading the excel/csv files run it via the Sql Server Agents. You can find details here https://learn.microsoft.com/en-us/sql/integration-services/load-data-to-from-excel-with-ssis?view=sql-server-2017

SQL statement for importing excel file

SELECT * INTO Data_dq
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Excel 12.0; Database=D:\Desktop\Data.xlsx', [Data$]);

https://learn.microsoft.com/en-us/sql/relational-databases/import-export/import-data-from-excel-to-sql?view=sql-server-2017

For CSV files https://learn.microsoft.com/en-us/sql/relational-databases/import-export/import-flat-file-wizard?view=sql-server-2017