Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

BULK INSERT won't ignore errors

Posted on 2004-04-21
1
Medium Priority
?
1,414 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

610 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