?
Solved

BULK INSERT won't ignore errors

Posted on 2004-04-21
1
Medium Priority
?
1,409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 34

Accepted Solution

by:
arbert earned 2000 total points
ID: 10885266
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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 the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

752 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