|
|
 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 3rd, 2004, 05:09 AM
|
|
Authorized User
|
|
Join Date: Mar 2004
Location: Amman, , Jordan.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Bulk insert
Hi all,
I am trying to use bulk insert and to overwrite the primary keys in the table(destination) with the ones in the text file (source), I am setting the MAxErrors option to 9999, but I am always getting the following error:
"Violation of PRIMARY KEY constraint 'PK_Testingbulk'. Cannot insert duplicate key in object 'Testingbulk'.
The statement has been terminated."
I dont want this statment to be cancelled even if there is errors, and i think maxerror option is the way to do that but its not working.
thanx in advance.
Regards,
|

March 3rd, 2004, 05:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,894
Thanks: 0
Thanked 10 Times in 9 Posts
|
|
How are you running the insert? Are you setting the KEEPIDENTITY flag?
--
Joe
|

March 3rd, 2004, 05:38 AM
|
|
Authorized User
|
|
Join Date: Mar 2004
Location: Amman, , Jordan.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
there is no identity columns in the table the only constraint is an integer primary key, and I want to replace the whole row of a primary key in the table with the same primary key coming from the text file, the insert is being called from a VB.Net code when a file is generated.
Regards,
Quote:
quote:Originally posted by joefawcett
How are you running the insert? Are you setting the KEEPIDENTITY flag?
--
Joe
|
|

March 3rd, 2004, 05:48 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,894
Thanks: 0
Thanked 10 Times in 9 Posts
|
|
As I understand it MaxErrors only means the procedure carries on after errors, it doesn't let you break constraints. Can you show your BULK INSERT query and your source and target table structure?
--
Joe
|

March 3rd, 2004, 05:53 AM
|
|
Authorized User
|
|
Join Date: Mar 2004
Location: Amman, , Jordan.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
As I know also if I have a duplicate key it should be considered as error and it should be skipped and the statment should complete normally, I am testing it on a simple table with 2 columns integer(PK)and nvarchar(2), my statment is
"BULK INSERT test.dbo.[testingbulk]
FROM 'c:\bulk.txt'
WITH
( datafiletype = 'char',
FIELDTERMINATOR = ',',
maxerrors = 1000,
KEEPIDENTITY
)"
thanx,
Quote:
quote:Originally posted by joefawcett
As I understand it MaxErrors only means the procedure carries on after errors, it doesn't let you break constraints. Can you show your BULK INSERT query and your source and target table structure?
--
Joe
|
|

March 3rd, 2004, 06:06 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,894
Thanks: 0
Thanked 10 Times in 9 Posts
|
|
Jus read the documentation again, seems MAXERRORS does not apply to constraint checks. I'll try to experiment a bit more.
--
Joe
|

March 4th, 2004, 03:09 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i think you have to remove temperory pk constraint , and all other constraints to avoid all errors and for fast copying and check for these constraints after copying, and redo relations.
Ahmed Ali
Software Developer
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Bulk Insert |
snufse |
SQL Server 2000 |
9 |
December 17th, 2007 06:53 AM |
| BULK INSERT FOR ARRAY |
MathLearner |
Beginning VB 6 |
4 |
September 28th, 2007 07:18 AM |
| bulk insert |
hymavathy_kr |
VB Databases Basics |
1 |
May 17th, 2007 07:47 AM |
| BULK INSERT NULL(s) |
nathansevugan |
SQL Server 2000 |
2 |
November 29th, 2005 12:11 AM |
| Bulk Insert |
luma |
SQL Server DTS |
1 |
July 13th, 2005 01:48 AM |
|
 |