Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql server replication

Posted on 2012-03-29
3
Medium Priority
?
249 Views
Last Modified: 2012-06-21
I want some way of doing replication in which only inserted and updated data gets replicated not the deleted one.

The idea is to build archiving database from the live db. but we want live db to be small.

1- Move changed data from live db to archive db
2- delete data from live db of older than today

we have to implement this in sql server. any other solution than replication.
0
Comment
Question by:Epurchase
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 100 total points
ID: 37782264
Your best option is to use triggers added to your tables.

http://msdn.microsoft.com/en-us/library/ms189799.aspx

also

http://msdn.microsoft.com/en-us/magazine/cc164047.aspx

After each 'Insert/Update' trigger you coudl write to another table in another database (if required) based on the values that were changed from the current row (that the trigger provides to you)  and then flush transactions from the bottom of your current table as required (or overnight using an SQL Agent Scheduled Task stored procedure).

The topic of triggers is too complicated to go into here - you will just need to go and read up about it but be warned you will almost certainly need to learn about stored procedures too (if you are not already familiar with them) as without them things get very complicated quite quickly.
0
 
LVL 1

Author Comment

by:Epurchase
ID: 37785818
Is there any way we can achieve the same using replication? I know the trigger option but wanted to do somehow using replication.
0
 
LVL 9

Expert Comment

by:lojk
ID: 37785900
Well, your original question ends..

"have to implement this in sql server. any other solution than replication."

Other than replication and using triggers, what else is there? clr doesn't supply any option that tsql doesn't already provide either.

I understand what you are trying to achieve I have done similar things too - using triggers, you could probably do something using a bunch of half baked client side code but it won't work (as well)

Have fun with this.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question