Solved

BULK INSERT won't ignore errors

Posted on 2004-04-21
1
1,398 Views
Last Modified: 2008-01-09
Dear Experts,

Here is a chunk of code that imports a text file of web stats into my offline Stats DB. Sometimes there is duplication between the records in the text file and records in the Stats DB (indicated by duplicate Primary key values). I want the system to ignore these records, which I thought it would do be setting MAXERRORS to a ridiculously high number, but VB just bugs out none the less complaining of duplicate primary keys. Anything I can do ?

 oCmd.ActiveConnection = cntDB
    sSQL = "BULK INSERT UMSTATSDB.dbo.[" & sTableName & "] " & _
        "FROM 'D:\UM Stats DB\TODO\" & sFilePath & "' " & _
        "WITH ( " & _
        "FIELDTERMINATOR = '}{', " & _
        "ROWTERMINATOR = ']|[', " & _
        "CHECK_CONSTRAINTS," & _
        "CODEPAGE = 'ACP', " & _
        "KEEPIDENTITY, " & _
        "KEEPNULLS, " & _
        "MAXERRORS=1000000" & _
        ")"

        oCmd.CommandText = sSQL
        oCmd.Execute
0
Comment
Question by:metalaureate
1 Comment
 
LVL 34

Accepted Solution

by:
arbert earned 500 total points
ID: 10885266
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AutoIncrement column based of FK 11 53
CDC and AOG on MS SQL 2012 13 23
Get Next number from Stored Procedure 8 21
SQL Availablity Groups Shared Path 2 13
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

792 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