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 2005 Forums
 Other SQL Server Topics (2005)
 Import script

Author  Topic 

sgunja
Starting Member

2 Posts

Posted - 2009-07-28 : 17:55:48
Hi guys

My SQL knowledge is pretty basic so I was wondering what is the best way to upload raw data files into SQL Server via a script. Currently, say if I have 15 different text files to import, I have to do them all manually and go through the import steps for each file. I was wondering if I keep say all the files in the folder and point the script to the folder, it would upload everything automatically.

Now this script may not have to be in SQL, it could be in another programming language, but does anyone have a clue where I could start?

Thanks

sgunja
Starting Member

2 Posts

Posted - 2009-07-28 : 18:02:24
To make it more clear, I want each raw data file to be a table. So if there are 15 raw data files, then when i run the script, I end up with 15 tables of the same name
Go to Top of Page

ldiprose
Starting Member

1 Post

Posted - 2009-07-29 : 21:41:34
First, use java to loop throught the folder containing the files you want to upload, and create a text file listing them file names and headers.
Then upload the text file to SQL server, and run a stored procedure that loops through the text file and creates a table then uses bulk insert to insert the data.
Go to Top of Page
   

- Advertisement -