all groups > sql server replication > september 2005 >
You're in the

sql server replication

group:

NOT FOR REPLICATION when manually replicating data



NOT FOR REPLICATION when manually replicating data jason.l.strauss NO[at]SPAM gmail.com
9/7/2005 1:49:40 AM
sql server replication: Hi folks!

I am wondering if anyone out there has been able to use the NOT FOR
REPLICATION field constraint when implementing a manual replication
process? From what I have read, only the inbuilt replication methods
can actually insert identity fields without SQL Server happily updating
it's identity seed automatically.

Unfortunately, I have a system I'm working on at the moment which
requires a complex multi-tier form of replication. After much
deliberation, soul searching and consulting of the I-Ching, we decided
it isn't feasible to use any of the merge or other stock replication
methods.

If anyone has found a way around this I would be extremely grateful if
you could give me a few tips!

Either that or perhaps someone out there has a lateral suggestion for
manually ensuring that seperate nodes in a replication system are able
to cross-replicate whilst continuing to use their own identity field
range?

Much thanks,

JLS
Re: NOT FOR REPLICATION when manually replicating data Hilary Cotter
9/7/2005 6:17:45 AM
IIRC you have to tag context_info in sysprocesses as a replication process
for the query engine to enforce the not for replication constraints.

Have a look at sp_MSsetcontext_replagent to understand how this works.
--
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
[quoted text, click to view]

Re: NOT FOR REPLICATION when manually replicating data jason.l.strauss NO[at]SPAM gmail.com
9/7/2005 5:11:25 PM
Hi again,

No luck unfortunately. I am using the script below to test.
I also tried setting context_info to 0xFFFFF....FF just to see if there
was another bit to set that would do it. No luck! The identity field is
still reseeded. If anyone has any ideas it would be much appreciated!

<SCRIPT>

CREATE TABLE MyTempTable
(
fldID int IDENTITY(1,1) NOT FOR REPLICATION PRIMARY KEY,
fldName nvarchar(255)
)

EXEC sp_MSsetcontext_replagent 4 -- MERGE agent type
--select context_info from master..sysprocesses where spid = @@SPID

INSERT INTO MyTempTable (fldName) VALUES ('1')

SET IDENTITY_INSERT MyTempTable ON
INSERT INTO MyTempTable (fldID, fldName) VALUES (100000000, '2')
SET IDENTITY_INSERT MyTempTable OFF

INSERT INTO MyTempTable (fldName) VALUES ('3')

SELECT * FROM MyTempTable order by fldName

DROP TABLE MyTempTable

</SCRIPT>
Re: NOT FOR REPLICATION when manually replicating data איל שפירא
9/12/2005 6:35:06 AM


AddThis Social Bookmark Button