Solved

BULK INSERT won't ignore errors

Posted on 2004-04-21
1
1,395 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
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now