Solved

Loading data via BCP when there are missing columns in text file

Posted on 2012-03-29
2
806 Views
Last Modified: 2012-04-10
Hi,
I have number of tables with NULL column values allowed within them.

I have data files which I need to import into these tables using BCP. As expected, BCP needs matching columns with text data and surely not the case here.

I can see suggestion of using format file but it's not working for me.

I don't want to hand edit tonnes of files.I need to know if there is an easy way to create format files  using  BCP switches or any other alternative?

Thanks
0
Comment
Question by:crazywolf2010
2 Comments
 
LVL 24

Accepted Solution

by:
DBAduck - Ben Miller earned 500 total points
ID: 37785451
You should look at the format file for bcp.

http://msdn.microsoft.com/en-us/library/ms191479.aspx

Look at the section that tells you about column order.  You can map the field 4 in the file to field 6 in the table.

And here is the reference for skipping the field in the table with the format file.

http://msdn.microsoft.com/en-us/library/ms179250.aspx
0
 

Author Comment

by:crazywolf2010
ID: 37786282
Hi,
Do I have to hand code each of the fmt file?


Thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question