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.
| Author |
Topic |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2007-05-06 : 07:41:18
|
i am using this code to insert rows from file into a tablei nthe DBfor %%f in ( %BULK_UPLOAD_BASE%\Temp\*.txt) do bcp "db1.dbo.TargetTable" in %%f -S SERVER1 -Usrv -h "TABLOCK" -e %BULK_UPLOAD_BASE%\Error\Err.txt -o %BULK_UPLOAD_BASE%\Logs\Output.txt -Preport2 -C RAW -f %BULK_UPLOAD_BASE%\format_RawData.fmt what i want to do is :to take only part of the "columns" from the file (which are seperated with TAB in a text files and upload them to the DB - but not all of the columns are in order of 1 after the other for example :col1,col2,col3,col4and i want only col1,col2,col4 )how can i do this?thnaksi n advancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-06 : 12:50:01
|
2 ways:1. use a format file with bcp2. bulk insert to a staging table, then select from there only the columns you want. www.elsasoft.org |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2007-05-07 : 03:33:02
|
i do u se a file format :-f %BULK_UPLOAD_BASE%\format_RawData.fmt Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
|
|
|