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
 Transact-SQL (2005)
 Bulk insert using format files how to map columns

Author  Topic 

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2010-11-29 : 07:11:30
How to insert text file having 3 columns into table having 5 columns

Example:
Table has id,name,age,salary,[phone number] columns and
text file having data for id,salary,age fields.

how to match text field columns with table fields using bulk insert with format files.

can any one please reply.

Thanks in advance!!!

IRK

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-29 : 07:19:22
Odd - this seems to be a duplicate but from a different user
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=153495

Anyway
Easiest way is to create a view on the table with the columns from the text file and bcp into that.
If you really wnat to use a format file have a look at
http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html


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

anonymust
Starting Member

1 Post

Posted - 2010-11-29 : 08:10:47
,

SQL-TIDU = Some Queer Language, That I Don't Understand
Go to Top of Page
   

- Advertisement -