473,795 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2592
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****@sommarsk og.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...@sommars kog.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...@sommarsk og.se

Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/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*******@gmai l.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****@sommarsk og.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
7960
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 columns). Some of my the files will have 419 columns some others files will have 421 columns. When my bulk insert script encounters a file with 419 colums it will put some of the data from the next line in the last 2 columns.
1
7565
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 until the very end of the backup process, when the backup is almost going to be over, the progress bar updates itself once on a stretch, which is no use,it is not showing any progress. SQLDMO documentation says, the SQLDMO.Backup object fires
2
5521
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) { progressBar1.Value = Percent; progressBar1.Update(); }
1
2558
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: "anonymous@discussions.microsoft.com" <anonymous@discussions.microsoft.com> Sent: 11/11/2004 5:52:10 AM
1
2024
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 'Filling Servers Name sqlNameList = sqlApp.ListAvailableSQLServers
3
7030
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 = oSQLServerDMOApp.ListAvailableSQLServers For i = 1 To namX.Count
3
1437
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 i As Integer
1
1850
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 (FAILED(hr)) { return; }
0
1701
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 have one letter in the customerID field (M123456). The field they are going into is VARCHAR(1000) . All of the integers go in correctly but for some reason the cutomerID values that stert with a letter (M123456) are NULL. Any help? I'm stumped. ...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.