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)
 BULK INSERT for fewer columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-09-26 : 08:28:16
Srinivas Reddy writes "Hello,

I'm having some data as shown below in varying textfiles ( of various names)
1,94000252,91845996, MEERA KHATAK ,18,94000252
2,94000252,97050199, PROMILA MATHUR ,18,94000252
I've a table called TABLE1 with 6 columns.
Using following BULK INSERT statement, I succeded in getting the records from textfile to the table.

exec ('BULK INSERT TABLE1 FROM ''c:\gene\11999284.txt'' WITH ( DATAFILETYPE = ''char'', FIELDTERMINATOR = '','', ROWTERMINATOR = ''\n'', KEEPNULLS)')

Now I've some other table with more number of columns than 6, and I don't want to increase the columns in the textfile.

And I want to use BULK INSERT Method for this.

Could some body please come with possible solution on how to go about it?

Thanks in advance.

Cheers
Srinivas Reddy"

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-09-26 : 09:13:30
1) Use a view
2) Use a staging table (always a good idea)
3) Use a format file for the BULK INSERT


HTH
Jasper Smith
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-09-26 : 09:57:54
I would go with
1) and 2) together.

Stick a datetime default getdate() and an identity on the staging table so you know when and in what order things happened.

Don't like format files - they get messy.

==========================================
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 -