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
 General SQL Server Forums
 New to SQL Server Programming
 load table scenario, how pros do

Author  Topic 

trento
Starting Member

13 Posts

Posted - 2009-08-05 : 22:42:38
Hi,
Just would like to get and idea how pros do in my situation:
I have tab-delimited raw file that hold 50+ columns and I need to load some of them into 20 columns table. I don't have an option to manipulate this raw file outside sql, so i'm thinking to do:

1. create table_50
2. bcp -in file50 into table_50
3. create table_20 as (select column1...column20 from table-50).
4. drop table_50


will appreciate you feedback. Idon't think i can do it directly in one load with bcp.

Thanks
trent

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2009-08-05 : 22:56:44
You shouldbe able to load table_20 directly from the data file with BCP using column mappings in a format file.

You could also use DTS or SSIS to load table_20 directly from the data file.



CODO ERGO SUM
Go to Top of Page

trento
Starting Member

13 Posts

Posted - 2009-08-06 : 00:29:40
Tx, MVJ
Will look into bcp option now, didn't know that.
Is it -h "hint [,...n]" option? Even if wanted columns don't go one after another ?
will appreaciate if anybody give me a sample bcp.
and I don't have an option to use dts, sisl or etc... just bcp.

tx again
t
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-08-06 : 06:41:04
Look in Books Online for "bcp format file". You have to dig a little bit, but they have an example of a format file that excludes columns, skips columns, etc.
Go to Top of Page
   

- Advertisement -