Inserting Rows into SQLServer from CSV file


insert into dbo.my_temp_table
([Texts])
(
SELECT *  FROM
OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DEFAULTDIR=\\ims01\Develop\Produktion\PartnerRohDaten\P200902\temp\;
Extensions=TXT;', 'SELECT * FROM [Received but not Processed.txt]')
)


declare @s varchar(400)
 set @s = 'BULK Insert my_temp_table
 FROM ''\\ims01\Develop\Produktion\PartnerRohDaten\P200902\temp\' + @file_name +
 ''' WITH
 (
  FIELDTERMINATOR = '','',
  ROWTERMINATOR = ''\n'',
  FIRSTROW = 1
    )'
 print @s
 exec(@s)