-1

I have a multiple text file and I want to insert it on a #Temp table. Below is the sample script I made.

create table #Temp
(
   Column1 Varchar(max), 
   Column2 Varchar(max), 
   Column2 Varchar(max)
)

BULK INSERT #Temp FROM 'C:\File1.txt' 
WITH (FIELDTERMINATOR =',')

select * from #Temp
drop table #Temp

Since my path is for File1.txt only, how can I insert the rest? *.txt doesn't work for me.

Please help!

Regards,

jarlh
  • 42,561
  • 8
  • 45
  • 63

1 Answers1

0

Use the information in the above link to get all the files with a required filemask from a folder.

How to list files inside a folder with SQL Server

Then you can store this list and pass one filename at a time to BULK INSERT command thru variable.

Hope this information helps.

Community
  • 1
  • 1