Solved

sql server replication

Posted on 2012-03-29
3
220 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 50 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create an aggregate function 9 36
SQL View nearest date 5 36
SQL Server Error 21 8 25
SQL invalid column name 5 13
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

803 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