Showing posts with label trigger. Show all posts
Showing posts with label trigger. Show all posts

Friday, March 30, 2012

Merge Replication: Insert Trigger ONLY when replicating

Hello,
I have a scenario where clients enter data into a MSDE local database on
their laptop. I would like to add a trigger on that table that fires only
on the Server (SQL2K Ent.) when they are synchronizing when a new records
has been inserted. By looking at the Merge trigger automaticcaly generated
on the table, I found something interesting:
"if sessionproperty('replication_agent') = 1 and (select
trigger_nestlevel()) = 1"
Therfore, I've created my trigger like the following:
Create Trigger tg_Inserted On tblBlaBla FOR INSERT
AS
if not sessionproperty('replication_agent') = 1
return
Insert Into tblTest (Account_Code, Product_Code, DateCreation)
Select ins.Account_code, ins.Product_Code, GetDate()
From Inserted As Ins
I've done some test and everything works fine. However, before putting this
in Production, I was wondering if I absolutely need to put the "Select
trigger_nestlevel() ..." or not. I've read in the newsgroups and some are
saying you need to, some are saying you don't need to... Since it is a very
well documented feature, can anyone confirm me the proper way of doing this?
That would be greatly appreciated. Thanks.
Nest level check allows to avoid ping-pong traffic from subscriber to
publisher and vice versa
But in your case that should matter only if you are also replicating table
tblTest
Regards,
Kestutis Adomavicius
Consultant
UAB "Baltic Software Solutions"
"Christian Hamel" <chamel@.NOSPAM.com> wrote in message
news:udebeQ7WFHA.2692@.TK2MSFTNGP15.phx.gbl...
Hello,
I have a scenario where clients enter data into a MSDE local database on
their laptop. I would like to add a trigger on that table that fires only
on the Server (SQL2K Ent.) when they are synchronizing when a new records
has been inserted. By looking at the Merge trigger automaticcaly generated
on the table, I found something interesting:
"if sessionproperty('replication_agent') = 1 and (select
trigger_nestlevel()) = 1"
Therfore, I've created my trigger like the following:
Create Trigger tg_Inserted On tblBlaBla FOR INSERT
AS
if not sessionproperty('replication_agent') = 1
return
Insert Into tblTest (Account_Code, Product_Code, DateCreation)
Select ins.Account_code, ins.Product_Code, GetDate()
From Inserted As Ins
I've done some test and everything works fine. However, before putting this
in Production, I was wondering if I absolutely need to put the "Select
trigger_nestlevel() ..." or not. I've read in the newsgroups and some are
saying you need to, some are saying you don't need to... Since it is a very
well documented feature, can anyone confirm me the proper way of doing this?
That would be greatly appreciated. Thanks.
|||Great. I'm not replicating this table. Thanks for the information.
"Kestutis Adomavicius" <kicker.lt@.noospaam_tut.by> wrote in message
news:eVz8BD8WFHA.1796@.TK2MSFTNGP15.phx.gbl...
> Nest level check allows to avoid ping-pong traffic from subscriber to
> publisher and vice versa
> But in your case that should matter only if you are also replicating table
> tblTest
> --
> Regards,
> Kestutis Adomavicius
> Consultant
> UAB "Baltic Software Solutions"
>
> "Christian Hamel" <chamel@.NOSPAM.com> wrote in message
> news:udebeQ7WFHA.2692@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I have a scenario where clients enter data into a MSDE local database
on
> their laptop. I would like to add a trigger on that table that fires only
> on the Server (SQL2K Ent.) when they are synchronizing when a new records
> has been inserted. By looking at the Merge trigger automaticcaly
generated
> on the table, I found something interesting:
> "if sessionproperty('replication_agent') = 1 and (select
> trigger_nestlevel()) = 1"
> Therfore, I've created my trigger like the following:
> Create Trigger tg_Inserted On tblBlaBla FOR INSERT
> AS
> if not sessionproperty('replication_agent') = 1
> return
> Insert Into tblTest (Account_Code, Product_Code, DateCreation)
> Select ins.Account_code, ins.Product_Code, GetDate()
> From Inserted As Ins
> I've done some test and everything works fine. However, before putting
this
> in Production, I was wondering if I absolutely need to put the "Select
> trigger_nestlevel() ..." or not. I've read in the newsgroups and some are
> saying you need to, some are saying you don't need to... Since it is a
very
> well documented feature, can anyone confirm me the proper way of doing
this?
> That would be greatly appreciated. Thanks.
>
|||I think it is to prevent recursive triggers from causing duplicate entries
in msmerge_contents. I could be wrong here.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Christian Hamel" <chamel@.NOSPAM.com> wrote in message
news:udebeQ7WFHA.2692@.TK2MSFTNGP15.phx.gbl...
> Hello,
> I have a scenario where clients enter data into a MSDE local database
on
> their laptop. I would like to add a trigger on that table that fires only
> on the Server (SQL2K Ent.) when they are synchronizing when a new records
> has been inserted. By looking at the Merge trigger automaticcaly
generated
> on the table, I found something interesting:
> "if sessionproperty('replication_agent') = 1 and (select
> trigger_nestlevel()) = 1"
> Therfore, I've created my trigger like the following:
> Create Trigger tg_Inserted On tblBlaBla FOR INSERT
> AS
> if not sessionproperty('replication_agent') = 1
> return
> Insert Into tblTest (Account_Code, Product_Code, DateCreation)
> Select ins.Account_code, ins.Product_Code, GetDate()
> From Inserted As Ins
> I've done some test and everything works fine. However, before putting
this
> in Production, I was wondering if I absolutely need to put the "Select
> trigger_nestlevel() ..." or not. I've read in the newsgroups and some are
> saying you need to, some are saying you don't need to... Since it is a
very
> well documented feature, can anyone confirm me the proper way of doing
this?
> That would be greatly appreciated. Thanks.
>

Monday, March 26, 2012

merge replication w PocketPC and trigger order

Hi
We've got a problen in a customer with SQL Server 2000 SP3 and merge
replication with PocketPC
We have some triggers FOR UPDATE on the same field used to distribute in
replication settings, so I suspect sometimes our triggers didn't work, and
sometimes the first trigger that has been executed were the replication
trigger.
Can I use the sp_settriggerorder to set the order to execute, setting the
replication trihgger as last in execution?
Thanks
Yes you can, I normally make them execute first though.
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Ricardo Snchez" <Ricardo Snchez@.discussions.microsoft.com> wrote in
message news:2BA27F4E-0454-4DC0-9DC2-46CD14C7E368@.microsoft.com...
> Hi
> We've got a problen in a customer with SQL Server 2000 SP3 and merge
> replication with PocketPC
> We have some triggers FOR UPDATE on the same field used to distribute in
> replication settings, so I suspect sometimes our triggers didn't work, and
> sometimes the first trigger that has been executed were the replication
> trigger.
> Can I use the sp_settriggerorder to set the order to execute, setting the
> replication trihgger as last in execution?
> Thanks
sql

Merge Replication trigger count

Hi,
I have Merge Replication ( Articles x,y) with Publications at 4 Sites and a
Central Subscriber. All the Merge Agents are running with property
-exchangetype 2 parameter
Article x have 12 triggers (4 for insert, 4 delete and 4 updates) which
looks OK ( 1 set for each publication) but article y has only 3 triggers(1
insert, i update and 1 delete). I am getting invalid following erros in the
conflict viewer:
1. The row was updated at 'SINDEV21.NewCase' but could not be updated at
'SINDEV20.NewCase'. Invalid object name
'ctsv_CAB6F215FE394ECAB4CE7DD56BD4B1B8'.
2. The row was updated at 'SINDEV21.NewCase' but could not be updated at
'SINDEV20.NewCase'. Unable to synchronize the row because the row was updated
by a different process outside of replication.
You need to reinitialize this subscription and resend your data. It looks
like your replication metadata is out of sync.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Vikas Kohli" <VikasKohli@.discussions.microsoft.com> wrote in message
news:7DC1A948-B930-45A1-ACFF-BB88246FBC16@.microsoft.com...
> Hi,
> I have Merge Replication ( Articles x,y) with Publications at 4 Sites and
a
> Central Subscriber. All the Merge Agents are running with property
> -exchangetype 2 parameter
> Article x have 12 triggers (4 for insert, 4 delete and 4 updates) which
> looks OK ( 1 set for each publication) but article y has only 3 triggers(1
> insert, i update and 1 delete). I am getting invalid following erros in
the
> conflict viewer:
> 1. The row was updated at 'SINDEV21.NewCase' but could not be updated at
> 'SINDEV20.NewCase'. Invalid object name
> 'ctsv_CAB6F215FE394ECAB4CE7DD56BD4B1B8'.
> 2. The row was updated at 'SINDEV21.NewCase' but could not be updated at
> 'SINDEV20.NewCase'. Unable to synchronize the row because the row was
updated
> by a different process outside of replication.
|||When I had first configured this, everything was OK. However to carry a
schema change activity, I had dropped all the subscriptions and Publications,
dropped all the replication procedures, triggers manually wherever required
and reconfigure the Replication again after the schema change. It has started
giving error after then.I have tried removing replication a number of times
but each time same problem.
Also please let me know what should be the normal count of Triggers at the
Central Subscriber, is it 12 or 4?
"Hilary Cotter" wrote:

> You need to reinitialize this subscription and resend your data. It looks
> like your replication metadata is out of sync.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Vikas Kohli" <VikasKohli@.discussions.microsoft.com> wrote in message
> news:7DC1A948-B930-45A1-ACFF-BB88246FBC16@.microsoft.com...
> a
> the
> updated
>
>
|||Just to add more...
I cant reinitialize the Replication since the Data volume is huge and I
can't send that accross WAN. I have to use the property 'do not initialize
Schema or data' when I add subscription.
"Vikas Kohli" wrote:
[vbcol=seagreen]
> When I had first configured this, everything was OK. However to carry a
> schema change activity, I had dropped all the subscriptions and Publications,
> dropped all the replication procedures, triggers manually wherever required
> and reconfigure the Replication again after the schema change. It has started
> giving error after then.I have tried removing replication a number of times
> but each time same problem.
> Also please let me know what should be the normal count of Triggers at the
> Central Subscriber, is it 12 or 4?
> "Hilary Cotter" wrote:
|||Hi,
Any help in this matter will be appreciated as we are encountering lot of
issues due to this
Vikas Kohli
"Vikas Kohli" wrote:
[vbcol=seagreen]
> Just to add more...
> I cant reinitialize the Replication since the Data volume is huge and I
> can't send that accross WAN. I have to use the property 'do not initialize
> Schema or data' when I add subscription.
> "Vikas Kohli" wrote:

Saturday, February 25, 2012

Merge Replication and Trigger Problem

Hi,
I have an issue with my replication at the moment. I will try to describe
the scenario accurately.
I am using MS SQL 2000 SP4 with Merge Replication. Users/Subscribers connect
to the publisher to upload/download changes. I have a trigger set up on one
table which updates another, here is an example of the trigger:
"CREATE TRIGGER qt_t_projTotal ON dbo.qt_quotes
FOR INSERT, UPDATE, DELETE
AS
declare @.projTotal as money
declare @.projId as int
declare @.projcurrtype as int
select @.projId = project_id from inserted
select @.projcurrtype = proj_curr_type from qt_projects where project_id =
@.projId
--Get project total from the sum of table [qt_quotes]
select @.projTotal = (select
sum(dbo.fConvertCurrency(quot_grnd_totl,quot_curr_ type,@.projcurrtype)) as
quoteTotal from qt_quotes where project_id = @.projId)
--Update projects record with new project total
update qt_projects
set proj_act_totl = @.projTotal
where project_id = @.projId"
I feel my trigger maybe setup incorrectly in that replication thinks an
insert is occurring instead of an update. (Im quite new to triggers) What is
happening is a conflict is occuring with the following message:
"The row was inserted at Server.Publisher' but could not be inserted at
'Subscriber.database'. INSERT statement conflicted with COLUMN FOREIGN KEY
constraint 'FK_qt_quotes_qt_projects'. The conflict occurred in database
'Publisher', table 'qt_projects', column 'project_id'."
What is also happening as a result of this conflict (I think) is the record
in question is getting deleted from the Publisher. This is causing huge
problems as it is proving quite difficult to get these records back in the
system due to identity values.
Can anyone guide me to what might be happeing here, is it the trigger?
Onre posible cause is that there is an indexed view which references the
table. If you do an update which affects the indexed view, SQL Server will
implement it as a deferred update ie a delete/insert pair. Please see
Simon's blog for more details:
http://sqljunkies.com/WebLog/simons/archive/2006/04/24/Indexed_view_update_performance.aspx
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Merge Replication and Trigger Problem

Hi,

I have an issue with my replication at the moment. I will try to
describe the scenario accurately.

I am using MS SQL 2000 SP4 with Merge Replication. Subscribers connect
to the publisher to upload/download changes. I have a trigger set up on
one table which updates another, here is an example of the trigger:

"CREATE TRIGGER qt_t_projTotal ON dbo.qt_quotes
FOR INSERT, UPDATE, DELETE
AS
declare @.projTotal as money
declare @.projId as int
declare @.projcurrtype as int

select @.projId = project_id from inserted
select @.projcurrtype = proj_curr_type from qt_projects where project_id
= @.projId

--Get project total from the sum of table [qt_quotes]
select @.projTotal = (select
sum(dbo.fConvertCurrency(quot_grnd_totl,quot_curr_ type,@.projcurrtype))
as quoteTotal from qt_quotes where project_id = @.projId)

--Update projects record with new project total
update qt_projects
set proj_act_totl = @.projTotal
where project_id = @.projId"

I feel my trigger maybe setup incorrectly in that replication thinks an
insert is occurring instead of an update. (Im quite new to triggers)
What is happening is a conflict is occuring with the following message:

"The row was inserted at Server.Publisher' but could not be inserted at
'Subscriber.database'. INSERT statement conflicted with COLUMN FOREIGN
KEY constraint 'FK_qt_quotes_qt_projects'. The conflict occurred in
database 'Publisher', table 'qt_projects', column 'project_id'."

What is also happening as a result of this conflict (I think) is the
record in question is getting deleted from the Publisher. This is
causing huge problems as it is proving quite difficult to get these
records back in the system due to identity values.

Can anyone guide me to what might be happeing here, is it the trigger?Benzine wrote:

Quote:

Originally Posted by

Hi,
>
I have an issue with my replication at the moment. I will try to
describe the scenario accurately.
>
I am using MS SQL 2000 SP4 with Merge Replication. Subscribers connect
to the publisher to upload/download changes. I have a trigger set up on
one table which updates another, here is an example of the trigger:
>
"CREATE TRIGGER qt_t_projTotal ON dbo.qt_quotes
FOR INSERT, UPDATE, DELETE
AS
declare @.projTotal as money
declare @.projId as int
declare @.projcurrtype as int
>
select @.projId = project_id from inserted
select @.projcurrtype = proj_curr_type from qt_projects where project_id
= @.projId
>
--Get project total from the sum of table [qt_quotes]
select @.projTotal = (select
sum(dbo.fConvertCurrency(quot_grnd_totl,quot_curr_ type,@.projcurrtype))
as quoteTotal from qt_quotes where project_id = @.projId)
>
--Update projects record with new project total
update qt_projects
set proj_act_totl = @.projTotal
where project_id = @.projId"
>


First thing to notice here is that your trigger is going to have issues
with any multi-row insert/update/delete statements. You need to get
that fixed.

However, I don't think that's your problem...

Quote:

Originally Posted by

I feel my trigger maybe setup incorrectly in that replication thinks an
insert is occurring instead of an update. (Im quite new to triggers)
What is happening is a conflict is occuring with the following message:
>
"The row was inserted at Server.Publisher' but could not be inserted at
'Subscriber.database'. INSERT statement conflicted with COLUMN FOREIGN
KEY constraint 'FK_qt_quotes_qt_projects'. The conflict occurred in
database 'Publisher', table 'qt_projects', column 'project_id'."
>
What is also happening as a result of this conflict (I think) is the
record in question is getting deleted from the Publisher. This is
causing huge problems as it is proving quite difficult to get these
records back in the system due to identity values.
>
Can anyone guide me to what might be happeing here, is it the trigger?


Merge replication is funny. So far as I can work out, in 2000, you
cannot force the merges to happen in a particular order. So it's
possible for it to merge data in the referencing table before it merges
data in the referenced table, for a particular foreign key.

In our systems, we've marked all of the foreign keys as "not for
replication", which has eliminated these kinds of errors for us. I'm
not sure what your options are if you cannot cope with "orphan" rows
appearing for brief moments of time.

On a side note (not applicable to OP), in 2005 you can specify the
order in which articles are processed. But I can't see how that can be
useful to anyone, since, in general, you would want to process inserts
in one order (for foreign keys to always work), and deletes in the
opposite order, surely?

Damien|||Thanks for your reply Damien,

Is unchecking "Enforce relationships for replication" the same as
marking FK "Not for Replication"

Damien wrote:

Quote:

Originally Posted by

Benzine wrote:

Quote:

Originally Posted by

Hi,

I have an issue with my replication at the moment. I will try to
describe the scenario accurately.

I am using MS SQL 2000 SP4 with Merge Replication. Subscribers connect
to the publisher to upload/download changes. I have a trigger set up on
one table which updates another, here is an example of the trigger:

"CREATE TRIGGER qt_t_projTotal ON dbo.qt_quotes
FOR INSERT, UPDATE, DELETE
AS
declare @.projTotal as money
declare @.projId as int
declare @.projcurrtype as int

select @.projId = project_id from inserted
select @.projcurrtype = proj_curr_type from qt_projects where project_id
= @.projId

--Get project total from the sum of table [qt_quotes]
select @.projTotal = (select
sum(dbo.fConvertCurrency(quot_grnd_totl,quot_curr_ type,@.projcurrtype))
as quoteTotal from qt_quotes where project_id = @.projId)

--Update projects record with new project total
update qt_projects
set proj_act_totl = @.projTotal
where project_id = @.projId"


First thing to notice here is that your trigger is going to have issues
with any multi-row insert/update/delete statements. You need to get
that fixed.
>
However, I don't think that's your problem...
>

Quote:

Originally Posted by

I feel my trigger maybe setup incorrectly in that replication thinks an
insert is occurring instead of an update. (Im quite new to triggers)
What is happening is a conflict is occuring with the following message:

"The row was inserted at Server.Publisher' but could not be inserted at
'Subscriber.database'. INSERT statement conflicted with COLUMN FOREIGN
KEY constraint 'FK_qt_quotes_qt_projects'. The conflict occurred in
database 'Publisher', table 'qt_projects', column 'project_id'."

What is also happening as a result of this conflict (I think) is the
record in question is getting deleted from the Publisher. This is
causing huge problems as it is proving quite difficult to get these
records back in the system due to identity values.

Can anyone guide me to what might be happeing here, is it the trigger?


>
Merge replication is funny. So far as I can work out, in 2000, you
cannot force the merges to happen in a particular order. So it's
possible for it to merge data in the referencing table before it merges
data in the referenced table, for a particular foreign key.
>
In our systems, we've marked all of the foreign keys as "not for
replication", which has eliminated these kinds of errors for us. I'm
not sure what your options are if you cannot cope with "orphan" rows
appearing for brief moments of time.
>
On a side note (not applicable to OP), in 2005 you can specify the
order in which articles are processed. But I can't see how that can be
useful to anyone, since, in general, you would want to process inserts
in one order (for foreign keys to always work), and deletes in the
opposite order, surely?
>
Damien

|||Benzine wrote:

Quote:

Originally Posted by

Thanks for your reply Damien,
>
Is unchecking "Enforce relationships for replication" the same as
marking FK "Not for Replication"
>


Um, yes, I believe so. (Being a poncy type, I tend to do all this kind
of work through writing SQL rather than using Enterprise Manager, but
it looks like it's the sensible choice).

Damien|||Damien wrote:

Quote:

Originally Posted by

On a side note (not applicable to OP), in 2005 you can specify the
order in which articles are processed. But I can't see how that can be
useful to anyone, since, in general, you would want to process inserts
in one order (for foreign keys to always work), and deletes in the
opposite order, surely?


I suppose it could work if (1) the order is reversed for deletes, either
automatically or by request, or (2) cascade-delete triggers are used.|||Thanks allot for your help.
I will make the changes and issue a new snapshot then cross my fingers.

On Jan 5, 1:02 am, "Damien" <Damien_The_Unbelie...@.hotmail.comwrote:

Quote:

Originally Posted by

Benzine wrote:

Quote:

Originally Posted by

Thanks for your reply Damien,


>

Quote:

Originally Posted by

Is unchecking "Enforce relationships for replication" the same as
marking FK "Not for Replication"Um, yes, I believe so. (Being a poncy type, I tend to do all this kind


of work through writing SQL rather than using Enterprise Manager, but
it looks like it's the sensible choice).
>
Damien

|||Hi Damien,

You wouldnt by chance have a script that can update the
status_for_replication to Not_For_Replication for all FK's?

Ben

On Jan 4, 7:37 pm, "Damien" <Damien_The_Unbelie...@.hotmail.comwrote:

Quote:

Originally Posted by

Benzine wrote:

Quote:

Originally Posted by

Hi,


>

Quote:

Originally Posted by

I have an issue with my replication at the moment. I will try to
describe the scenario accurately.


>

Quote:

Originally Posted by

I am using MS SQL 2000 SP4 with Merge Replication. Subscribers connect
to the publisher to upload/download changes. I have a trigger set up on
one table which updates another, here is an example of the trigger:


>

Quote:

Originally Posted by

"CREATE TRIGGER qt_t_projTotal ON dbo.qt_quotes
FOR INSERT, UPDATE, DELETE
AS
declare @.projTotal as money
declare @.projId as int
declare @.projcurrtype as int


>

Quote:

Originally Posted by

select @.projId = project_id from inserted
select @.projcurrtype = proj_curr_type from qt_projects where project_id
= @.projId


>

Quote:

Originally Posted by

--Get project total from the sum of table [qt_quotes]
select @.projTotal = (select
sum(dbo.fConvertCurrency(quot_grnd_totl,quot_curr_ type,@.projcurrtype))
as quoteTotal from qt_quotes where project_id = @.projId)


>

Quote:

Originally Posted by

--Update projects record with new project total
update qt_projects
set proj_act_totl = @.projTotal
where project_id = @.projId"First thing to notice here is that your trigger is going to have issues


with any multi-row insert/update/delete statements. You need to get
that fixed.
>
However, I don't think that's your problem...
>

Quote:

Originally Posted by

I feel my trigger maybe setup incorrectly in that replication thinks an
insert is occurring instead of an update. (Im quite new to triggers)
What is happening is a conflict is occuring with the following message:


>

Quote:

Originally Posted by

"The row was inserted at Server.Publisher' but could not be inserted at
'Subscriber.database'. INSERT statement conflicted with COLUMN FOREIGN
KEY constraint 'FK_qt_quotes_qt_projects'. The conflict occurred in
database 'Publisher', table 'qt_projects', column 'project_id'."


>

Quote:

Originally Posted by

What is also happening as a result of this conflict (I think) is the
record in question is getting deleted from the Publisher. This is
causing huge problems as it is proving quite difficult to get these
records back in the system due to identity values.


>

Quote:

Originally Posted by

Can anyone guide me to what might be happeing here, is it the trigger?Merge replication is funny. So far as I can work out, in 2000, you


cannot force the merges to happen in a particular order. So it's
possible for it to merge data in the referencing table before it merges
data in the referenced table, for a particular foreign key.
>
In our systems, we've marked all of the foreign keys as "not for
replication", which has eliminated these kinds of errors for us. I'm
not sure what your options are if you cannot cope with "orphan" rows
appearing for brief moments of time.
>
On a side note (not applicable to OP), in 2005 you can specify the
order in which articles are processed. But I can't see how that can be
useful to anyone, since, in general, you would want to process inserts
in one order (for foreign keys to always work), and deletes in the
opposite order, surely?
>
Damien- Hide quoted text -- Show quoted text -

|||Benzine wrote:

Quote:

Originally Posted by

Hi Damien,
>
You wouldnt by chance have a script that can update the
status_for_replication to Not_For_Replication for all FK's?
>
Ben
>


I'm afraid not. I believe that the first time I encountered this
problem for a project, what I ended up doing was scripting out all of
the foreign keys to a script file. Then using an editor with support
for regular expressions in find and replace (in my case, Visual
Studio), I edited the file to include the "NOT FOR REPLICATION" at the
appropriate places in the file (see Books On Line for ALTER TABLE to
find the right syntax). Then I wrote another script which just tore
down all existing foreign keys in the database. Applying these scripts
in the correct order produced the necessary changes.

On the second project, I had it included from the start, so I've never
had to do this again.

Damien|||Thanks again.

Damien wrote:

Quote:

Originally Posted by

Benzine wrote:
>

Quote:

Originally Posted by

Hi Damien,

You wouldnt by chance have a script that can update the
status_for_replication to Not_For_Replication for all FK's?

Ben


I'm afraid not. I believe that the first time I encountered this
problem for a project, what I ended up doing was scripting out all of
the foreign keys to a script file. Then using an editor with support
for regular expressions in find and replace (in my case, Visual
Studio), I edited the file to include the "NOT FOR REPLICATION" at the
appropriate places in the file (see Books On Line for ALTER TABLE to
find the right syntax). Then I wrote another script which just tore
down all existing foreign keys in the database. Applying these scripts
in the correct order produced the necessary changes.
>
On the second project, I had it included from the start, so I've never
had to do this again.
>
Damien