Using BCP to Import
Hi
I'm using the BCP facility to import a text file into a database. My problem is, in the table there are 10 fields but my file only contains data for 3 fields
e.g
Table - id,forname,surname,dob,gender,mob_number
File - forname,surname,mob_number
is there a way of only importing into the required fields or do i have to have columns in the order they are in, in the table??
can I use this file??
matt,jones,0775446644
chris,jones,066565465
or do i have to use this?
,matt,jones,,,0775446644
,chris,jones,,,066565465
[591 byte] By [
minckle] at [2007-11-20 9:53:28]

# 1 Re: Using BCP to Import
There's information about the utility here:
http://msdn2.microsoft.com/en-us/library/ms162802.aspx
If you're going to perform the import often, you could look into creating a format file (I'm not sure how it works, though, but more information is available from the above link). Otherwise, you could just import all the columns into a new table, and then do a simple SQL query to import only the columns you want:
SELECT DEFAULT, Forename, Surname, DEFAULT, DEFAULT, Mob_Number
INTO Customers
FROM TempTable