Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 Import multiple files from folder

Author  Topic 

christian-hansen
Starting Member

3 Posts

Posted - 2014-07-03 : 03:17:49
Hello,
I need to import a lot of document from a folder to my sql server.
Can i do that with a bulk insert?
Each day there is coming a new file in the folder, and filename is the current date. So each day there comes a file with the date as file name. Is there a way just to import all files in the folder? or an easy way to automatic import the newest file from the folder?
Can anyone help me?

Regards Christian.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-07-03 : 03:55:35
1. Create a variable to reflect current date.
2. Use a FOREACHLOOP container with a file mask from the variable created in step 1.



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

christian-hansen
Starting Member

3 Posts

Posted - 2014-07-03 : 05:22:23
So if we take the code it is something like:

DECLARE @CurrentTime DATETIME
set @CurrentTime = GETDATE()

And how should the bulk then look like?

Regards Christian
Go to Top of Page

christian-hansen
Starting Member

3 Posts

Posted - 2014-07-03 : 05:23:13
I mean the FOREACHLOOP*
:)

Regards Christian.
Go to Top of Page
   

- Advertisement -