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)
 Importing from text files to tables dynamically

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-25 : 09:14:04
Forrest writes "I am trying to import from a text file into a sql table based on the first field in the the delimitted file. The file would look like:
tableName,field1,field2
tableName,field1,field2,field3

where each tableName is diferent. I have tried using the BULK INSERT function, and cannot see how to switch the tables dynamically. I am running Windows 2000 Server running SQL 7.0 and 2000. Any help here would be greatly appreciated. Thanks so much."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-01-25 : 12:18:42
To be honest, keeping data meant for multiple tables in one text file is not a good idea...it cause problems like the one you're experiencing, among others, and there's no benefit at all. If you can split each table's data into separate files then you can BULK INSERT no problem.

DTS is highly programmable, you could write some code to parse out the table name and change the transformation accordingly. If you don't like that idea, I'm afraid I can't think of another one, that's the nature of the problem you have. Again, try creating separate text files for each table and load them individually.

Go to Top of Page
   

- Advertisement -