Search code examples
sql-serverdatabasebcp

Is there any way we can resume file load from nth line in a bcp utility instead of loading the file from the beginning?


I'm loading a data file to a SQL server database using bcp utility. There are some scenarios where while loading huge files, the load fails at mid way due to connectivity issues.

I can identify how many records are loaded in database. Assuming n records are loaded, is there a way we can resume loading of file in the bcp from n+1 th line instead of from the 1st line? Is there any parameter we can give in the bcp command to make this work?


Solution

  • Yes. BCP has a -F parameter that will let you specify a 1-based offset. So, if you wanted to skip the first 1000 rows, you'd do:

    bcp yourdb.dbo.yourtable in yourfile.bcp -F 1001 ...