Solved

BULK INSERT won't ignore errors

Posted on 2004-04-21
1
1,403 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 500 total points
ID: 10885266
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

688 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