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

sql server replication

group:

replication without deletes?


replication without deletes? Sherpa
9/30/2004 12:31:51 PM
sql server replication:
Hello All,

I have a database that is going to be replicated. I need to keep only
about 3 months worth of data but the replicated database needs to keep
about 3 years worth of data for reporting. What's the easiest way to do
this? Is there a way to have replication not replicate the deletes?
I really only dealing with one table in the database.

Thanks in advance.

RE: replication without deletes? v-mingqc NO[at]SPAM online.microsoft.com (
10/1/2004 5:15:22 AM
Hi Sherpa,

From your descriptions, I understood that you would like to filter the data
within three months. Have I understood you? Correct me if I was wrong.

Based on my scope, your table must have an column to specify the datetime
like this

CREATE TABLE [dbo].[Table1] (
[c1] [char] (10) NULL ,
[d1] [datetime] NOT NULL ,
[c2] [char] (10) NULL
) ON [PRIMARY]
GO

Then, you could use Data Filter to define the data you want to replicated
vertically and horizontally. Like the sampel below, you could noticed that
where clause is defined in @filter_clause as d1< getdate() and d1
[quoted text, click to view]

-- Adding the article's partition column(s)
exec sp_articlecolumn @publication = N'mingqing', @article = N'Table1',
@column = N'c1', @operation = N'add'
GO
exec sp_articlecolumn @publication = N'mingqing', @article = N'Table1',
@column = N'd1', @operation = N'add'
GO

-- Adding the article filter
EXEC sp_articlefilter @publication = N'mingqing', @article = N'Table1',
@filter_name = N'dbo.FLTR_Table1_1__51', @filter_clause = N'd1< getdate()
and d1 >dateadd(month, -3,getdate())'
GO

In the dynamic filter, you can specify a function or a user-defined
function that is evaluated differently for each Subscriber based on the
connection properties of the Merge Agent when the merge process is
replicating data between the Subscriber and Publisher. Besides HOST_NAME(),
the system function SUSER_SNAME() can also be used for this purpose.

You can also use a user-defined function in a dynamic filter, but unless
the user-defined function definition includes SUSER_SNAME(), HOST_NAME(),
or the user-defined function evaluates one of these system functions in the
filter criteria (such as MyUDF(SUSER_SNAME()), the user-defined function
will be static.


Thank you for your patience and corperation. If you have any questions or
concerns, don't hesitate to let me know. We are here to be of assistance!


Sincerely yours,

Mingqing Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---------------------------------------------------------------
Introduction to Yukon! - http://www.microsoft.com/sql/yukon
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!

replication without deletes? Paul Ibison
10/1/2004 8:33:28 AM
If you are using Transactional Replication, you can type
none, for the delete command to be replicated
(sp_addarticle, @del_cmd = NONE).
HTH,
Paul Ibison

(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
Re: replication without deletes? Sherpa
10/1/2004 11:09:54 AM
you missunderstood perhaps I should have explained better.

On my publisher I want 3 months,
My subscriber I would like 3 years.

any ideas?



[quoted text, click to view]

Re: replication without deletes? Hilary Cotter
10/2/2004 8:51:34 PM
you have to encorporate the delete functionality into your custom delete
replication stored procedure. This is what your custom delete proc would
look like

create procedure "sp_MSdel_authors" @pkc1 varchar(11)
as
delete "authors"
where "au_id" = @pkc1 and DateColumn > getdate()-90

--if @@rowcount = 0
-- if @@microsoftversion>0x07320000
-- exec sp_MSreplraiserror 20598

GO



--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html


[quoted text, click to view]

Re: replication without deletes? v-mingqc NO[at]SPAM online.microsoft.com (
10/5/2004 8:59:58 AM
Hi Sherpa,

I would like to thanks Hilary Cotter for his greatest solution for this
issue.

I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!

Sincerely yours,

Mingqing Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---------------------------------------------------------------
Introduction to Yukon! - http://www.microsoft.com/sql/yukon
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!
AddThis Social Bookmark Button