I have a folder with dozens of files. The files all have a .txt file extension, even though they are comma deliminated.
I would like to create a SQL Server stored procedure that does the following, when given a directory path and a specific database, creates a new table in the database for each file. The table name will be the file name, and the table data will be the data within the file.
For example, file "xxABC.txt" has 500 records in comma separated format (excluding header). The procedure will create table xxABC and then insert 500 rows into the table.
I've found how to list files in a directory using SQL Server (How to list files inside a folder with SQL Server), but still trying to figure out how to create tables based on files.