March 9, 2009 at 8:42 pm
Hello,
I have a question about importing data in SQL 2000. I have 3 CSV files that I want to import into the same table. They have the same number of fields, same format in each of the fields, etc. Assuming I can't merge the files manually and import them as one merged file, is there a way to import the CSV files into the same table (i.e. import one data file and import the remaining two files to the table that importing the first one created)? I would greatly appreciate any information that anyone could provide.
Thanks.
March 14, 2009 at 8:25 am
You can use DTS to import the CSV files one by one.
March 14, 2009 at 9:55 am
See this article on Looping, Importing and Archiving files in DTS Packages using ActiveX Script
--Ramesh
March 14, 2009 at 10:37 am
Ramesh (3/14/2009)
See this article on Looping, Importing and Archiving files in DTS Packages using ActiveX Script
Just do 3 simple bulk inserts. It's also one of the fastest ways to do it.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 14, 2009 at 11:00 am
Jeff Moden (3/14/2009)
Ramesh (3/14/2009)
See this article on Looping, Importing and Archiving files in DTS Packages using ActiveX ScriptJust do 3 simple bulk inserts. It's also one of the fastest ways to do it.
Jeff, you were right, it can also be done using BULK INSERT statement and some other methods as well. Actually, today, I was answering questions more about SSIS/DTS. So, I was in an impression of it, suggested the OP to use DTS. Though, I still suggest him to use DTS instead of BULK INSERT/OPENROWSET methods, 'cause I'm thinking that there are not just 3 files. There could be more than that or may be in future it will.
In case of n files, if we use BULK INSERT you have to use shell commands to read file names from the directory and loop through each file, which requires permissions on procedure xp_cmdshell and BULK ADMINISTRATORS role and most DBAs are reluctant to give permissions on these objects. Or let the application loop through directory and call the BULK INSERT procedure for each file and archive the file that are imported.
--Ramesh
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply