Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 BCP Switches

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-13 : 20:02:41
Selva writes "Hi,

I have a problem on BCP and the issue goes below.

I need to insert rows into a table on SOL Server database, which already has rows. Assume the table has defined with Primary key. I need to use only BCP for this purpose, as this has to take place during the product database installation/upgrade during InstallShield installation program run.

I insert the rows by running BCP. The command I use is given below.

Bcp jmopn..jmeror in c:\jmopn\install\dba\jmeror.unl -b 1 -m 1000 -T -c -t \"|\" -r \\n -o c:\jmopn\install\dba\jmeror.log

Where

jmopn - my database name
jmeror - my table name
jmeror.unl - my datafile
jmeror.log - my log file

I am using –b 1 and –m 1000 switches so that I can have batch size as 1 row and maximum error counts as 1000. I am using these switches because of the foll. reason.

Suppose if the table has already row(s) which are having same primary key column value identical to the row(s) to be inserted from the datafile, I want to generate the log file with an error saying that particular record was violating primary key and to continue inserting the rest of the rows.

But obviously my intention was not met, as the above command did not work. The problem I noted is, when any row is violating the primary key that row is not inserted and the Bcp terminates without giving an attempt to insert the rest of the records.

I am not sure if this known issue/bug in BCP itself. I would be thankful if you could suggest a workaround/fix for my problem.

I am using SQL Server 7 with SP2 and NT 4.0 with SP5.

Thanks.
Selva
(selva@maxwell.com)
"
   

- Advertisement -