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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 data import

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-07-12 : 07:11:39
Mike writes "I have a need for a procedure that imports text files into sql server 2000. The file format is not fixed, it may have different columns, the file will always be comma delimited.

I would like to write one procedure that can import any text file into a new table in the database.

Any ideas on how to do this? DTS possibly?

Thanks for the help.

-Mike"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-12 : 07:23:14
Bulk Insert will do this job but the number of columns and datatypes should match with the table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-07-12 : 09:15:48
see
http://www.mindsdoor.net/SQLTsql/ImportTextFiles.html

That will import any file as long as the row width is less than 8000 chars (you will come across some interesting bugs in bcp and bulk insert for longer rows).
Change the merge sp to cater for moving the data to the tables.

also see
http://www.mindsdoor.net/SQLTsql/MoveImportData.html
for doing tthe move based on metadata.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -