473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SQLDMO.Bulkcopy diagnostics on failed load

I use SQLDMO.Bulkcopy in an VB6 (have to) program to load data from a
plain text file into a SQL Server 2000.
One of the target columns is NOT NULL but it happens that I receive a
missing value for that column in the source file. BulkCopy then has an
ODBC error raised that complains about the violated NOT NULL
constraint. The Bulkcopy error file however is empty. Is there a way
to figure out in which row of the source file the error occured ?
Maybe a call to some ODBC diagnostics method to receive further
information ? I'd like to avoid the obvious solution to drop the
constraint and then query the loaded data for NULL values.
Thanks
Nils
Dec 9 '07 #1
3 2574
Nils (de*@nils-dehn.de) writes:
I use SQLDMO.Bulkcopy in an VB6 (have to) program to load data from a
plain text file into a SQL Server 2000.
One of the target columns is NOT NULL but it happens that I receive a
missing value for that column in the source file. BulkCopy then has an
ODBC error raised that complains about the violated NOT NULL
constraint. The Bulkcopy error file however is empty. Is there a way
to figure out in which row of the source file the error occured ?
Maybe a call to some ODBC diagnostics method to receive further
information ? I'd like to avoid the obvious solution to drop the
constraint and then query the loaded data for NULL values.
The common approach it to use a staging table and move on from there,
but that is of course an extra that you may want to avoid if this
happens rarely.

It seems that NOT NULL errors are not logged in the error file. Furthermore,
the appear to cause bulk load to terminate directly. (I tried command-
line which uses ODBC as well.) You could set the batchsize to 1,
in that case the bulkload will load all record up to the erroneous
record. (But beware that a batchsize of 1 can severely affect performacne
for large files. If you are loading into a new table without indexes,
this can also lead to a disk explosion.)

If this is a one-off, try using BULK INSERT instead. When I tested, I
got a clear error message which said:
"The bulk load failed. Unexpected NULL value in data file row 3, column 1.
The destination column (a) is defined as NOT NULL."
Furthermore, when I used BATCHSIZE = 1, all rows but the bad one was
loaded. I should hasted to add that I did all these tests with SQL 2005,
but I would expect SQL 2000 to be the same.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 9 '07 #2
On Dec 9, 5:31 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
Nils (d...@nils-dehn.de) writes:
I use SQLDMO.Bulkcopy in an VB6 (have to) program to load data from a
plain text file into a SQL Server 2000.
One of the target columns is NOT NULL but it happens that I receive a
missing value for that column in the source file. BulkCopy then has an
ODBC error raised that complains about the violated NOT NULL
constraint. The Bulkcopy error file however is empty. Is there a way
to figure out in which row of the source file the error occured ?
Maybe a call to some ODBC diagnostics method to receive further
information ? I'd like to avoid the obvious solution to drop the
constraint and then query the loaded data for NULL values.

The common approach it to use a staging table and move on from there,
but that is of course an extra that you may want to avoid if this
happens rarely.

It seems that NOT NULL errors are not logged in the error file. Furthermore,
the appear to cause bulk load to terminate directly. (I tried command-
line which uses ODBC as well.) You could set the batchsize to 1,
in that case the bulkload will load all record up to the erroneous
record. (But beware that a batchsize of 1 can severely affect performacne
for large files. If you are loading into a new table without indexes,
this can also lead to a disk explosion.)

If this is a one-off, try using BULK INSERT instead. When I tested, I
got a clear error message which said:
"The bulk load failed. Unexpected NULL value in data file row 3, column 1.
The destination column (a) is defined as NOT NULL."
Furthermore, when I used BATCHSIZE = 1, all rows but the bad one was
loaded. I should hasted to add that I did all these tests with SQL 2005,
but I would expect SQL 2000 to be the same.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Erland, how do use BATCHSIZE = 1? I don't have SQL server here right
now but wonder how to use BATCHSIZE. I use BULK INSERT. MAN! is it
quick.

TIA
Dec 10 '07 #3
scoots987 (sc*******@gmail.com) writes:
Erland, how do use BATCHSIZE = 1? I don't have SQL server here right
now but wonder how to use BATCHSIZE. I use BULK INSERT. MAN! is it
quick.
There is a sample command:

bulk insert fritte from 'C:\temp\slask.bcp'
with (datafiletype = 'char', fieldterminator = ',',
batchsize = 1, errorfile = 'C:\temp\slask.err')

BATCHSIZE = 1 is something you would only use for troubleshooting,
as it cut performance quite a bit.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 10 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: silven | last post by:
Hi all I am trying to do a Bulk Copy from a "tab delmimited" text file to a table in my database. I have it almost working except when the file has too few columns for the table (table has 421...
1
by: | last post by:
Hi all My requirement is to "on button_click, backup a SQL database using SQLDMO.Backup object and update the progress in a ProgressBar. The problem is the progress bar does not update at all...
2
by: | last post by:
Hi all, continued from yesterday's posting... I still haven't found a solution to this issue. I put a breakpoint in private void SqlBackupPercentComplete(string message, int Percent) {...
1
by: | last post by:
Hi all I am posting this to check if anyone could help me. The problem still persists. I am beginner in C#. Thanks. Subject: SQLDMO.Backup and ProgressBar - help please From: ...
1
by: Craig G | last post by:
i have the following code in a form load event, that (should) simply populate a combobox with the names of all SQL servers on the network Dim x As Long Dim sqlNameList As SQLDMO.NameList ...
3
by: Zack Sessions | last post by:
I am using VB.NET 2003. I found the following sample code here in an article: Dim oSQLServerDMOApp As New SQLDMO.Application Dim i As Integer Dim namX As SQLDMO.NameList namX =...
3
by: Brian Henry | last post by:
Anyone know why this would happen... I added a reference to the SQLDMO COM object, imported it on top of my code.. then this test code fails Imports SQLDMO Module Module1 Sub Main() Dim...
1
by: Mark Findlay | last post by:
My C++ .Net project currently uses smart points for SQLDMO object manipulation: SQLDMO::_SQLServerPtr spSQLServer; HRESULT hr = spSQLServer.CreateInstance(__uuidof(SQLDMO::SQLServer)); if...
0
by: wisaunders | last post by:
the file I'm importing has > 200,000 records I have one problem: One of the columns in the .txt file (customerID) has almost all Inetger values except for about 30 records. Those 30 records...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.