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)
 Using bulk insert how can i insert using format fi

Author  Topic 

sathishmangunuri
Starting Member

32 Posts

Posted - 2010-11-29 : 06:58:38
how to insert data into table having 5 columns and text file having 3 columns.

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

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

could any one explain me please.

Thanks in advance!!!

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-29 : 07:00:44
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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-29 : 08:39:12
Also refer
http://beyondrelational.com/blogs/madhivanan/archive/2010/03/17/bulk-insert-to-table-with-specific-columns.aspx

Madhivanan

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

- Advertisement -