By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,046 Members | 2,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,046 IT Pros & Developers. It's quick & easy.

bcp & trigger: got missiing data in bcp out files

P: n/a
I have a trigger 'trgTblUpdate' working on the table 'Tbl'. When the
table 'Tbl' got inserted/updated data, the tigger is fired and then we
use a batch file with bcp command to unload those new inserted/updated
data to another server. But in bcp out file, it didn't get all new
inserted/updated data, there are some missing data. I am not sure if I
explain it clearly. Could you help me out of this problem???? I am
stuggling for that these two days............Any help is appreciated.

1. code for trigger:

CREATE TABLE [TblUpdate] (
[id] [int] NOT NULL ,
[eventid] [int] NOT NULL ,
[sequenceid] [int] NOT NULL ,
[UpdatePass] [int] NULL
) ON [PRIMARY]
GO
create trigger trgTblUpdate on Tbl For Insert,Update as
insert into TblUpdate(id,eventid,sequenceid) select ins.id,
ins.eventid,ins.sequenceid from inserted ins

2. bcp code in the Batch file:
isql -U <user-P <pw-S <server-Q "update AA..TblUpdate set
UpdatePass=1 where UpdatePass is null"

bcp "select a.* from AA..Tbl a, AA..TblUpdate b where
a.eventid=b.eventid and a.sequenceid=b.sequenceid and b.eventid<>-1
and b.sequenceid<>-1 and b.updatepass=1" queryout 30sec-%TFN_NOW%.wrk -
U <user-P <pw-S <server-f Tbl.fmt

isql -U <user-P <pw-S <server-Q "delete from AA..TblUpdate where
UpdatePass=1"

Jan 31 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Maybe you already had some rows with UpdatePass=1, before the update
was started. Or maybe you have some rows where the eventid and/or
sequenceid is not -1.

Razvan

Feb 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.